What is constructor?
Constructor is just like a method with same name of class that is used to initialize the state of an object. It is invoked at the time of object creation.
What is the purpose of default constructor?
The default constructor provides the default values to the objects. The java compiler creates a default constructor only if there is no constructor in the class.
Does constructor return any value?
yes, that is current instance
Is constructor inherited?
No, constructor is not inherited.
Can you make a constructor final?
No, constructor can't be final.
Q. If we are using both constructor and Setter method of a bean to set property of a bean class then with which value it will be set , with value given in constructor or setter method ?
Ans : Answer to this question in detail can be found here
No comments:
Post a Comment