Question-15: What is constructor?
Answer:
Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation.
Question-16: What is the purpose of default constructor?
Answer:
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.
Questiom-17: Does constructor return any value?
Answer:
yes, that is current instance (You cannot use return type yet it returns a value).
Question-18: Is constructor inherited?
Answer:
No, constructor is not inherited.
Question-19: Can you make a constructor final?
Answer:
No, constructor can’t be final.
Answer:
Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation.
Question-16: What is the purpose of default constructor?
Answer:
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.
Questiom-17: Does constructor return any value?
Answer:
yes, that is current instance (You cannot use return type yet it returns a value).
Question-18: Is constructor inherited?
Answer:
No, constructor is not inherited.
Question-19: Can you make a constructor final?
Answer:
No, constructor can’t be final.
No comments:
Post a Comment