?
What is the return type of a constructor in Java?
Answer & Solution
Correct Answer:
Option
C
Constructors are special methods in Java used to create objects of a class.
They have the same name as the class itself.
Unlike other methods, constructors don't have an explicit return type.
Their job is to initialize the object's member variables (fields) with values.
Therefore, they implicitly return a reference to the newly created object.
The correct answer is option C, because it correctly states the return type is implicitly the same as the class name.
They have the same name as the class itself.
Unlike other methods, constructors don't have an explicit return type.
Their job is to initialize the object's member variables (fields) with values.
Therefore, they implicitly return a reference to the newly created object.
The correct answer is option C, because it correctly states the return type is implicitly the same as the class name.
Join the Discussion
Login to post a comment or share your explanation.
Login