Computer Applications
Which of the following is true for the given object creation statement?
Game cricket = new Game();
- Game is an object of cricket class
- New keyword creates object Game
- Game is a class and cricket is an object
- Game and cricket are objects
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.
Related Questions
Select the infinite loop:
- for(int i = 1; i <= 10; i++)
- for(int i = 2; i != 0; i -= 3)
- for(int i = 5; i <= 5; i++)
- for(int i = 1; i >= 1; i--)
The output of
Math.max(-7, Math.min(-5, -4))is:- -5
- -4
- -7
- error
Post Office is an example for …………… access specifier.
- public
- local
- protected
- private
Assertion (A): In switch case, break statement avoids fall through.
Reason (R): break statement helps to execute only one case at a time.
- Both (A) and (R) are true and (R) is a correct explanation of (A).
- Both (A) and (R) are true and (R) is not a correct explanation of (A).
- (A) is true and (R) is false.
- (A) is false and (R) is true.