1.

The objects allocated using new operator ________________(a) Are destroyed when they go out of scope(b) Are not destroyed even if they go out of scope(c) Are destroyed anytime(d) Are not destroyed throughout the program executionThis question was posed to me in exam.Query is from New Operator in portion Memory Allocation & Scope of Variable of Object Oriented Programming

Answer»

The CORRECT OPTION is (b) Are not destroyed even if they go out of scope

To explain I would SAY: It is not necessary that the objects get destroyed when they go out of scope if allocated by using NEW operator. This is because new operator RETURNS a pointer to object that it had allocated. A suitable pointer with proper scope should be defined by the programmer explicitly.



Discussion

No Comment Found

Related InterviewSolutions