Java OCA OCP Practice Question 157

Question

Which best describes what the new keyword does?

  • A. Creates a copy of an existing object and treats it as a new one
  • B. Creates a new primitive
  • C. Instantiates a new object
  • D. Switches an object reference to a new one


C.

Note

The new keyword is used to call the constructor for a class and instantiate an instance of the class.

A primitive cannot be created using the new keyword.

Dealing with references happens after the object created by new is returned.




PreviousNext

Related