Advertisements
Advertisements
प्रश्न
A constructor ______ (can/cannot) be called as other functions.
रिकाम्या जागा भरा
Advertisements
उत्तर
A constructor cannot be called as other functions.
Explanation:
- Regular methods can be called explicitly at any time using an object name (e.g., object.methodName()).
- A constructor, however, can only be invoked once when an object is being born, using the new keyword. You cannot call a constructor later in the program to run its code again.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 4: Constructors - Exercises [पृष्ठ ११५]
