ICSE · Class 9 · Computer Applications
Class 9 Elementary Concept of Objects and Classes Mock Test (ICSE)
6 practice questions from Elementary Concept of Objects and Classes, in the style of your board paper, each with a worked answer and the marks for every step. Then take a full chapter test on paper, snap the pages and get every step marked.
Topics in Elementary Concept of Objects and Classes
- Objects as instances of a class
- Attributes and behaviour
- Class as an object factory
- Class as a user-defined data type
- Real-world modelling with classes
Elementary Concept of Objects and Classes practice questions with answers
- Q1Multiple choice1 markWhich of the following best describes a class in Java?
- (a)A named block of statements that performs a specific task
- (b)A user-defined blueprint from which objects are created
- (c)An instance that occupies memory and holds its own data values
- (d)A built-in data type that stores a single simple value
Show answer and step marks
- Correct option: (b) A user-defined blueprint from which objects are created+1
Answer: (b) - Q2Multiple choice1 markWhat is created in memory when the new operator is invoked with a class constructor?
- (a)An instance or object of the class
- (b)A static member function
- (c)A primitive data value
- (d)A new class definition file
Show answer and step marks
- Correct option: (a)+1
Answer: (a) - Q3Short answer2 marksStudy the Java class and the code that uses it. class Mobile { String brand; int price; } Mobile m1 = new Mobile(); Mobile m2 = new Mobile(); m1.price = 15000; m2.price = m1.price - 3000; m1.price = m1.price + 500; (a) How many objects of the class Mobile are created by the code above? [1] (b) State the value of m2.price after all the statements have run. [1]
Show answer and step marks
- Two objects, m1 and m2, are created with new Mobile(), so the count is 2.+1
- m2.price = 15000 - 3000 = 12000; the later change to m1.price does not alter m2.price, so the value is 12000.+1
Answer: (a) 2 objects; (b) m2.price = 12000 - Q4Short answer2 marksA class Bicycle has the data members gears and speed, and the method applyBrake(). Explain how the attributes of a Bicycle object differ from its behaviour, using these members in your answer.
Show answer and step marks
- Attributes are the data members that describe the state or properties of an object, such as gears and speed.+1
- Behaviour is what the object can do, carried out by its methods; applyBrake() changes the speed stored in the object.+1
Answer: Attributes store the state of a Bicycle object (gears, speed), while behaviour is the set of actions it performs through methods such as applyBrake(). - Q5Long answer4 marksA school wants a Java program to keep its student register. The register must hold the records of three students: Anita (roll number 14), Ravi (roll number 22) and Meena (roll number 9). (a) Name the class that should be written to describe every student in the register. [1] (b) Name the object that stores the record of Ravi (roll number 22). [1] (c) State whether the class you named in (a) is a primitive or a non-primitive data type. Give a reason. [1] (d) State how many objects of this class are needed to model the three students Anita, Ravi and Meena. [1]
Show answer and step marks
- (a) Student class, the blueprint that describes each student in the register.+1
- (b) A Student object for Ravi with roll number 22, an instance of the Student class.+1
- (c) Non-primitive (user-defined) data type, because it is not one of Java's built-in primitive types such as int or char and it groups several details together.+1
- (d) 3 objects, one each for Anita, Ravi and Meena.+1
Answer: (a) Student class; (b) Ravi's Student object (roll number 22); (c) Non-primitive (user-defined) data type; (d) 3 objects - Q6Long answer4 marksDefine a class named `MovieTicket` to act as a user-defined data type with the following specifications: Instance variables / data members: - `title` - of type String to store the movie title - `rating` - of type double to store the movie rating - `price` - of type double to store the ticket price Member methods: - `void accept()` - to accept the movie title, rating, and price using the Scanner class. - `void display()` - to display the ticket details. Write the complete Java program including the `main` method to create an object of this class and invoke the member methods.
Show answer and step marks
- Imports `java.util.Scanner` and declares class `MovieTicket` with instance variables `String title`, `double rating` and `double price`.+1
- `accept()`: creates a `Scanner` object and reads `title` with `nextLine()` (also credit `next()`).+0.5
- `accept()`: reads `rating` and `price` with `nextDouble()`.+0.5
- `display()`: prints the title, rating and price using `System.out.println`.+1
- `main`: creates an object with `MovieTicket ticket = new MovieTicket();`.+0.5
- `main`: calls `ticket.accept()` and then `ticket.display()`.+0.5
Answer: import java.util.Scanner; class MovieTicket { String title; double rating; double price; void accept() { Scanner sc = new Scanner(System.in); System.out.print("Enter the movie title: "); title = sc.nextLine(); System.out.print("Enter the rating: "); rating = sc.nextDouble(); System.out.print("Enter the ticket price: "); price = sc.nextDouble(); } void display() { System.out.println("Movie title: " + title); System.out.println("Rating: " + rating); System.out.println("Ticket price: " + price); } public static void main(String[] args) { MovieTicket ticket = new MovieTicket(); ticket.accept(); ticket.display(); } }
Take a full Elementary Concept of Objects and Classes test
PrepitUp writes a fresh paper on this chapter at the length you pick. Write it on paper with a timer, photograph the pages, and see the marks for every step and what to practise next.
- 15 min10 marks
- 30 min20 marks
- 1.5 hr40 marks
- 3 hr80 marks
Get your Elementary Concept of Objects and Classes answers marked
Sign in, pick this chapter and a length, write the test on paper and get every step marked.
Sign in to take this test