1.

What happens when new fails?(a) Returns zero always(b) Throws an exception always(c) Either throws an exception or returns zero(d) Terminates the programI had been asked this question in my homework.The doubt is from New Operator topic in division Memory Allocation & Scope of Variable of Object Oriented Programming

Answer»

Correct option is (c) Either THROWS an exception or returns ZERO

For explanation: While creating new objects, the new operator MAY fail because of MEMORY errors or due to PERMISSIONS. At that moment the new operator returns zero or it may throw an exception. The exception can be handled as usual.



Discussion

No Comment Found

Related InterviewSolutions