Which of the following statements correctly creates an object of a class named 'Dog'?

  • Dog dog = new Dog();
  • Dog obj = createObject();
  • Dog.create();
  • Dog.new();
To create an object of a class named 'Dog' in Java, you should use the class name followed by the constructor using the new keyword, like this: Dog dog = new Dog();. The other options are not the correct way to create an object of a class in Java.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *