Ask Question
17 September, 18:55

What happens when a returntype, even void, is specified as a constructor in Java?

+5
Answers (1)
  1. 17 September, 20:49
    0
    If a returntype is added to a constructor method in Java, it ceases to be a constructor and behaves like an ordinary class method with the same name as class name.

    Explanation:

    If a returntype is added to a constructor method in Java, it ceases to be a constructor and behaves like an ordinary class method with the same name as class name.

    Constructors are special methods which are used for initializing the object. Constructors do not have a return type. If we add a return type to the constructor method, it does not play any role during object initialization and can be involved like any other object method.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What happens when a returntype, even void, is specified as a constructor in Java? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers