1.

When is the memory allocated for an object gets free?(a) At termination of program(b) When object goes out of scope(c) When main function ends(d) When system restartsI have been asked this question during an interview for a job.Enquiry is from Memory Allocation of Object in portion Object of Object Oriented Programming

Answer»

The correct CHOICE is (b) When object GOES out of scope

Easy explanation - Whenever an object goes out of scope, the deletion of allocation memory takes PLACE. ACTUALLY the data is not deleted, instead the memory SPACE is flagged to be free for further use. Hence whenever an object goes out of scope the object members become useless and hence memory is set free.



Discussion

No Comment Found

Related InterviewSolutions