Advertisements
Advertisements
Question
A constructor has the ______ (same/different) name as that of the class.
Fill in the Blanks
Advertisements
Solution
A constructor has the same name as that of the class.
Explanation:
In languages like Java, a constructor must perfectly match the spelling and case of the class name. This allows the computer to instantly recognize it as an initialization block rather than a regular method.
shaalaa.com
Is there an error in this question or solution?
