मराठी

Explain the usage of the new operator in Java.

Advertisements

प्रश्न

Explain the usage of the new operator in Java.

स्पष्ट करा
Advertisements

उत्तर

The new operator in Java is used to create an object or instance of a class dynamically during program execution. It allocates memory for the object and invokes the constructor of the class to initialise the object.

  1. Object Creation: The new operator is used to create an instance of a class in Java.
  2. Memory Allocation: It dynamically allocates memory for the newly created object during program execution.
  3. Constructor Invocation: It automatically calls the constructor of the class to initialise the object.
  4. Reference Assignment: It returns a reference to the newly created object, which can be stored in a reference variable.
  5. Array Creation: The new operator is also used to create arrays in Java.
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 4: Objects - EXERCISE [पृष्ठ १०७]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 4 Objects
EXERCISE | Q 8. | पृष्ठ १०७
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×