Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which keyword is used to create an object in Java ?

  • A.create
  • B.object
  • C.make
  • D.new

Answer: D

Objects in Java are created with the new keyword.

new allocates memory for an object on the heap, calls the class constructor to initialise it, and returns a reference to it, as in Student s = new Student();.

create, object and make are not Java keywords. They could be used as ordinary identifiers, but none of them creates an object.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.