CONSTRUCTOR
Constructor is a special type of member function which name is the same as that class which contents it. It does not have any return type even void it must be public. It is used to initializes the required data members of the class.
It is automatically called when we create the object of the class.
There are three types of the constructor.
1. Default
constructor
The constructor has which does not have any parameter us known as default constructor.
2. Parameterized constructor
The constructor which having a set of the variable of the parameter is known as parameter constructor.
3.Copy constructor
The constructor which having a set of the object as the parameter is known as copy constructor.
Final Keyword
- Class Final
- Method Final
- Field Final
- Object Final
1.Class Final
2.Method final
If we declared a method as a final method then we
cannot change the implementation of that method.
Example.
3.Field Final.
If we declared a field as a final field then we
cannot change the value of that field throughout the program. In java final
field is equivalent to the constant of c /c++.
Example.
4.Object Final.
If we declared an object as a final object then
we cannot change their reference once allocated.
Example.
No comments:
Post a Comment