Computer Applications

Which of the following is true for the given object creation statement?

Game cricket = new Game();

  1. Game is an object of cricket class
  2. New keyword creates object Game
  3. Game is a class and cricket is an object
  4. Game and cricket are objects

Java Classes

6 Likes

Answer

Game is a class and cricket is an object

Reason — In the statement Game cricket = new Game();, Game is the name of the class, and cricket is the object (or instance) created from that class. The new keyword is used to create a new object of the class. Therefore, Game is the class, and cricket is the object.

Answered By

4 Likes


Related Questions