InterviewSolution
Saved Bookmarks
| 1. |
When is the memory allocated for an object?(a) At declaration of object(b) At compile time(c) When object constructor is called(d) When object is initialized to another objectThe question was posed to me in an interview for internship.My doubt stems from Memory Allocation of Object topic in division Object of Object Oriented Programming |
|
Answer» RIGHT answer is (C) When object constructor is called For explanation: The object memory allocation TAKES place when the object constructor is called. Declaration of an object doesn’t mean that memory is ALLOCATED for its members. If object is initialized with another object, it may just GET a reference to the previously created object. |
|