Object Oriented Programming Quiz

Grade 10 · Technology · Quiz

Test your understanding of OOP concepts including classes, objects, and the four pillars.

Questions

  1. In Java, which keyword is used to create a new object from a class?

    1. create
    2. new
    3. object
    4. instantiate
    Show answer

    Answer: new

    The 'new' keyword in Java is used to create (instantiate) a new object from a class.

  2. Which of the following best describes encapsulation?

    1. A class inheriting methods from another class
    2. Hiding internal data and exposing only necessary methods
    3. One method working differently on different data types
    4. 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.

  3. 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?

    1. Overloading
    2. Overriding
    3. Encapsulating
    4. 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.

  4. Which access modifier makes a class member accessible only within the same class?

    1. public
    2. protected
    3. private
    4. default
    Show answer

    Answer: private

    The 'private' access modifier restricts access to the member only within the class it is defined in.

  5. An abstract class in OOP is best described as:

    1. A class that can be instantiated directly to create objects
    2. A class that contains only static methods
    3. A class that cannot be instantiated and may define abstract methods for subclasses to implement
    4. 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.

  6. Method overloading refers to:

    1. A subclass replacing a parent class method
    2. Defining multiple methods with the same name but different parameters in the same class
    3. Using an interface to define method signatures
    4. 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.

  7. 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.

  8. 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.