ICSE Class 10 Computer Applications Question 12 of 30

Solved 2024 Question Paper ICSE Class 10 Computer Applications — Question 17

Back to all questions
17
Question

Question 1(xvii)

The correct statement to create an object named mango of class fruit:

  1. Fruit Mango= new fruit();
  2. fruit mango = new fruit();
  3. Mango fruit=new Mango();
  4. fruit mango= new mango();
Answer

fruit mango = new fruit();

Reason — In Java, creating an object follows the syntax:

ClassName objectName = new ClassName();

Where:

  • ClassName: The name of the class.
  • objectName: The name of the object.
  • new: Allocates memory for the object.
  • ClassName(): Calls the class's constructor.

Thus, fruit mango = new fruit(); correctly creates mango named object of fruit class.