Object Oriented Programming Quiz
Grade 10 · Technology · Quiz
Test your understanding of OOP concepts including classes, objects, and the four pillars.
Questions
In Java, which keyword is used to create a new object from a class?
- create
- new
- object
- instantiate
Show answer
Answer: new
The 'new' keyword in Java is used to create (instantiate) a new object from a class.
Which of the following best describes encapsulation?
- A class inheriting methods from another class
- Hiding internal data and exposing only necessary methods
- One method working differently on different data types
- Creating multiple objects from the same class
Show answer
Answer: Hiding internal data and exposing only necessary methods
Encapsulation bundles data and methods together and restricts direct access to internal state, exposing only what is necessary.
What is the term for a method in a subclass that has the same name and signature as a method in its superclass but provides a different implementation?
- Overloading
- Overriding
- Encapsulating
- Abstracting
Show answer
Answer: Overriding
Overriding occurs when a subclass provides its own implementation of a method already defined in the superclass, using the same method signature.
Which access modifier makes a class member accessible only within the same class?
- public
- protected
- private
- default
Show answer
Answer: private
The 'private' access modifier restricts access to the member only within the class it is defined in.
An abstract class in OOP is best described as:
- A class that can be instantiated directly to create objects
- A class that contains only static methods
- A class that cannot be instantiated and may define abstract methods for subclasses to implement
- A class that inherits from two parent classes simultaneously
Show answer
Answer: A class that cannot be instantiated and may define abstract methods for subclasses to implement
An abstract class cannot be instantiated directly; it serves as a base for subclasses that must implement any abstract methods declared in it.
Method overloading refers to:
- A subclass replacing a parent class method
- Defining multiple methods with the same name but different parameters in the same class
- Using an interface to define method signatures
- Preventing a method from being accessed outside its class
Show answer
Answer: Defining multiple methods with the same name but different parameters in the same class
Method overloading allows a class to have multiple methods with the same name but different parameter lists, enabling different behaviors based on input.
A class can inherit from multiple parent classes in Java (without using interfaces).
Show answer
Answer: False
Java does not support multiple inheritance of classes (to avoid the 'diamond problem'), but a class can implement multiple interfaces.
In OOP, a class acts as a ________ for creating objects.
Show answer
Answer: blueprint
A class defines the structure (attributes) and behavior (methods) that its objects will have — it is essentially a blueprint or template.
Get a personalized course on Object Oriented Programming built around your child.