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 [पृष्ठ ११५]
