ICSE · Class 10 · Computer Applications
Class 10 Class as the Basis of All Computation Mock Test (ICSE)
6 practice questions from Class as the Basis of All Computation, 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 Class as the Basis of All Computation
- Objects and classes
- Members of a class: data and methods
- Access specifiers: private, public, protected
- Instance and class (static) variables
- Object creation with new
Class as the Basis of All Computation practice questions with answers
- Q1Multiple choice1 markWhich of the following statements correctly instantiates an object of a class named Student?
- (a)new ob = Student();
- (b)Student ob = Student.new();
- (c)new Student ob = Student();
- (d)Student ob = new Student();
Show answer and step marks
- Correct option: (d)+1
Answer: (d) - Q2Multiple choice1 markWhich access specifier restricts the visibility of a member exclusively to within its own defined class?
- (a)default
- (b)protected
- (c)private
- (d)public
Show answer and step marks
- Correct option: (c)+1
Answer: (c) - Q3Multiple choice1 markWhat are the two primary components that make up the body of a Java class?
- (a)Keywords and operators
- (b)Instance variables and methods
- (c)Packages and interfaces
- (d)Constructors and primitives only
Show answer and step marks
- Correct option: (b)+1
Answer: (b) - Q4Short answer2 marksDifferentiate between an instance variable and a static (class) variable based on their memory allocation and sharing among objects.
Show answer and step marks
- Memory allocation: every object created with `new` gets its own separate copy of an instance variable, whereas a static variable has only a single copy for the whole class.+1
- Sharing: an instance variable belongs to one object and exists only as long as that object, whereas a static variable belongs to the class itself, is set up only once and is shared by all objects; it exists even when no object has been created.+1
Answer: Each object gets its own copy of an instance variable, which exists with that object; a static variable has one copy belonging to the class, set up once, shared by all objects and existing even without any object. - Q5Long answer4 marksDefine a class named `Movie` with the following specifications: Instance variables: - `title` of type String - `rating` of type double Methods: - `Movie(String t, double r)`: a parameterized constructor to initialize the instance variables. - `void display()`: to display the title and rating of the movie. Write a complete Java class with a `main` method. Inside the `main` method, use the `new` operator to create an object of the `Movie` class with the arguments "Inception" and 8.8, and invoke the `display()` method.
Show answer and step marks
- Class declaration `class Movie` with instance variables `String title; double rating;`.+1
- Parameterised constructor `Movie(String t, double r) { title = t; rating = r; }`.+1
- `void display()` printing the title and the rating with `System.out.println`.+1
- `main` creating the object with `Movie m = new Movie("Inception", 8.8);` and calling `m.display();`.+1
Answer: class Movie { String title; double rating; Movie(String t, double r) { title = t; rating = r; } void display() { System.out.println("Title: " + title); System.out.println("Rating: " + rating); } public static void main(String args[]) { Movie m = new Movie("Inception", 8.8); m.display(); } } - Q6Long answer4 marksDefine a class named Book with the following specifications: - Member variables: title (of type String), price (of type double). - Member methods: - Parameterized constructor Book(String t, double p) to assign values to the member variables. - Method display() to output the book title and price. Write a main method to instantiate an object of the Book class using the new operator, passing "Java Programming" and 450.0 as arguments, and invoke the display method using the created object.
Show answer and step marks
- Class declaration `class Book` with member variables `String title; double price;`.+1
- Parameterised constructor `Book(String t, double p) { title = t; price = p; }`.+1
- `void display()` printing the title and the price.+1
- `main` creating the object with `Book b = new Book("Java Programming", 450.0);` and calling `b.display();`.+1
Answer: class Book { String title; double price; Book(String t, double p) { title = t; price = p; } void display() { System.out.println("Title: " + title); System.out.println("Price: " + price); } public static void main(String args[]) { Book b = new Book("Java Programming", 450.0); b.display(); } }
Take a full Class as the Basis of All Computation 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 Class as the Basis of All Computation 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