Advertisements
Advertisements
Question
A constructor may have different names than the class name.
Options
True
False
MCQ
True or False
Solution
This statement is False.
Explanation:
In Java (and many other object-oriented programming languages), a constructor's name must match the class to which it belongs. This is a significant factor because the constructor is called automatically when an object of the class is created, and having the same name guarantees that the constructor is appropriately identified.
shaalaa.com
Is there an error in this question or solution?