Ask Question

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

+1
Answers (1)
  1. 25 January, 07:28
    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?
Find an answer to your question 👍 “What happens when a returntype, even void, is specified as a constructor in Java? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers