Basic of Class

A class is a template, use to create an object.
A class is made up of a members which consists of fields and methods, fields are the variable which hold the state for the object and methods are the operation an object can do.
Constructor is a special type of method use to initialize the object, or use to initialize the default values for the fields.It doesn’t have a return value since it implicitly return the object.
To be accessible from another class it is defined with the public access modifier.
If constructor is not declared for the class, compiler create the default constructor for it with 0(zero) arguments at the runtime.
this: Is a special keyword use to access the current instance of a class.
We can overload the constructor for different parameters.
We can call the another constructor from one: syntaxt this(p1, p2);

Advertisements

#class