Computer Applications
What is constructor? When is it invoked?
Java Constructors
ICSE 2014
7 Likes
Answer
A constructor is a member method that is written with the same name as the class name and is used to initialize the data members or instance variables. A constructor does not have a return type. It is invoked at the time of creating any object of the class.
Answered By
5 Likes
Related Questions
Assertion: A class can have multiple constructors.
Reason: Multiple constructors are defined with same set of arguments.
- Assertion is true, Reason is false.
- Both assertion and Reason are false.
- Both assertion and Reason are true.
- Assertion is false, Reason is true.
If the name of the class is "Yellow", what can be the possible name for its constructors?
- yellow
- YELLOW
- Yell
- Yellow