1.

Which of these operators is used to allocate memory for an object?(a) malloc(b) alloc(c) new(d) giveThis question was posed to me during an online interview.This interesting question is from Class Fundamentals & Declaring objects topic in chapter Classes and Methods of Java

Answer»

The correct choice is (C) new

The EXPLANATION is: Operator new dynamically ALLOCATES MEMORY for an object and returns a reference to it. This reference is address in memory of the object ALLOCATED by new.



Discussion

No Comment Found

Related InterviewSolutions