Which of the following ways is the correct way to create an object in Java?

64. Which of the following ways is the correct way to create an object in Java?

  1. Using the new keyword
  2. Using newInstance() method
  3. clone() method
  4. All of these

Answer: D) All of these

Explanation:

All of the above-mentioned ways are the correct way to create an object Java.

There are five different ways to create an object and we will see the ways to create an object given below:

  1. Using the new keyword
  2. Using newInstance() method of Class
  3. Using clone() method
  4. Using newInstance() method of Constructor class
  5. Using deserialization

Read more: Different ways to create an object in Java

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.