1.

If an object is allocated using new operator ____________(a) It should be deleted using delete operator(b) It can’t be deleted using delete operator(c) It may or may not be deleted using delete operator(d) The delete operator is not applicableI got this question at a job interview.My enquiry is from Delete Operator topic in section Memory Allocation & Scope of Variable of Object Oriented Programming

Answer»

Right option is (a) It should be DELETED USING delete operator

The best I can explain: The new operator allocates an OBJECT in memory and hence the memory ALLOCATION is bit different from usual allocation of an object. The delete operator can be used to delete the memory allocated for an object.



Discussion

No Comment Found

Related InterviewSolutions