Posts

Showing posts from October, 2017

Java Methods

A method is a function. A method name can be any name and identifying the return type is maditory. Ex:   1. public int max(){}       ↑ access modifier is not manditory.   2. void area(int length){} It's just like functions in C language.

Java Class

A class is like a blueprint, it contains different kinds of things such as variables,methods,constructors etc. Let's see how to declare a class. A class name should start from a capital letter.        Ex: class HelloWorld{} Accessibility of variables can be changed according to Access Modifiers . There are four types of access modifiers. Private - visible only within the class. Protected - visible to any other class in the same package. Public - visible to any class. Default - same as protected. Visible to any other class in the same package. (-) mark is used to denote private variables. (+) mark is used to denote public variables. Ex: -name:String        private String name; +mark:int       public int mark;