state the purpose of new operator with one example in java
Answers
Answered by
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
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
Physics,
6 months ago
Environmental Sciences,
6 months ago
Math,
11 months ago
Geography,
1 year ago