Computer Science, asked by abhisingh15, 11 months ago

state the purpose of new operator with one example in java

Answers

Answered by anupama777vidya
9

Answer:

The 'new' operator in java is responsible for the creation of new object or we can say instance of a class.

Actually, it dynamically allocates memory in the heap with the reference we define pointed from the stack.

obj = new Demo();

Answered by miachel
8

Answer:This reference is then stored in the variable. Thus, in Java, all class objects must be dynamically allocated. The new operator is also followed by a call to a class constructor, which initializes the new object. A constructor defines what occurs when an object of a class is created.

Explanation:

Similar questions