Object-Oriented Programming (OOP): Concepts and Pillars: 21 MCQs with answers

All 21 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 11 questions

Q1. Which statement best describes OOP?

Beginner
A A paradigm where data and methods are combined into objects
B A paradigm that avoids using real-life objects
C A paradigm that emphasises functions over data
D A paradigm where data and functions stay separated
Show the answer

A · A paradigm where data and methods are combined into objects

OOP is a programming paradigm based on objects, where data and methods are combined into a single unit.

Q2. In procedural programming, what is emphasised?

Beginner
A Classes
B Inheritance
C Functions
D Objects
Show the answer

C · Functions

Procedural programming keeps data and functions separated and emphasises functions.

Q3. How many pillars does OOP have according to the chapter?

Beginner
A Four
B Three
C Six
D Five
Show the answer

C · Six

The chapter lists six pillars: Class, Object, Encapsulation, Abstraction, Inheritance, Polymorphism.

Q4. Which of the following is NOT one of the six pillars of OOP?

Beginner
A Compilation
B Inheritance
C Encapsulation
D Polymorphism
Show the answer

A · Compilation

Compilation is not a pillar. The six pillars are Class, Object, Encapsulation, Abstraction, Inheritance, Polymorphism.

Q5. What is a class?

Beginner
A A relationship between two objects
B A method that hides data
C A blueprint describing attributes and behaviours
D An instance created from a design
Show the answer

C · A blueprint describing attributes and behaviours

A class is the blueprint of an object; it describes attributes and behaviours but cannot hold data directly.

Q6. What is an object?

Beginner
A A method for hiding complexity
B A blueprint of a class
C A type of access modifier
D An instance of a class
Show the answer

D · An instance of a class

An object is the instance of a class, created from the class design.

Q7. A red Toyota Corolla and a blue Honda Civic built from the same car design are examples of:

Beginner
A Abstract interfaces
B Objects of the class Car
C Two different classes
D Encapsulated methods
Show the answer

B · Objects of the class Car

They are objects created from the class 'Car', each with its own attribute values.

Q8. Which pillar bundles data and methods while restricting direct access?

Beginner
A Inheritance
B Abstraction
C Encapsulation
D Polymorphism
Show the answer

C · Encapsulation

Encapsulation bundles data and methods into a single unit and restricts direct access using access modifiers.

Q9. Which access modifiers are used by encapsulation to hide internal state?

Beginner
A Final and abstract
B Public and static
C Virtual and override
D Private and protected
Show the answer

D · Private and protected

Encapsulation uses access modifiers such as private and protected to hide internal state.

Q10. Which pillar hides complex implementation details and shows only essential features?

Beginner
A Encapsulation
B Inheritance
C Abstraction
D Polymorphism
Show the answer

C · Abstraction

Abstraction hides complex implementation details and shows only the essential features to the user.

Q11. OOP has six pillars — Class, Object, Encapsulation, Abstraction, Inheritance, and Polymorphism — not the four commonly quoted.

Beginner
A True
B False
Show the answer

A · True

OOP has six pillars — Class, Object, Encapsulation, Abstraction, Inheritance, and Polymorphism — not the four commonly quoted.

Building up · 5 questions

Q12. Pressing the channel button on a remote without knowing the internal circuit is an example of:

Intermediate
A Inheritance
B Encapsulation
C Abstraction
D Polymorphism
Show the answer

C · Abstraction

The channel button is an abstraction: you use the essential feature without knowing the complex internals.

Q13. Which mechanism lets a child class acquire properties and methods from a parent class?

Intermediate
A Encapsulation
B Inheritance
C Abstraction
D Polymorphism
Show the answer

B · Inheritance

Inheritance is the mechanism where a derived/child class acquires properties and methods from a base/parent class.

Q14. Which relationship does inheritance establish?

Intermediate
A A 'part-of' relationship
B An 'is-a' relationship
C A 'has-a' relationship
D A 'uses-a' relationship
Show the answer

B · An 'is-a' relationship

Inheritance establishes an 'is-a' relationship, e.g., a sports car is a car.

Q15. Which of these is a type of inheritance named in the chapter?

Intermediate
A Parallel
B Multilevel
C Sequential
D Recursive
Show the answer

B · Multilevel

The chapter names single, multiple, multilevel, hierarchical, and hybrid inheritance.

Q16. What does polymorphism mean in OOP?

Intermediate
A Acquiring properties from a parent class
B Creating a blueprint for objects
C Hiding data behind access modifiers
D Expressing various behaviours through the same interface
Show the answer

D · Expressing various behaviours through the same interface

Polymorphism means 'many forms' — expressing various forms or behaviours through the same interface.

Topper level · 5 questions

Q17. Given the following class structure, identify the correct statement regarding the `SportsCar` class and its relationship with the `Car` class: ```python class Car: def __init__(self, model): self.model = model class SportsCar(Car): def __init__(self, model, speed): super().__init__(model) self.speed = speed ```

Advanced
A `Car` cannot be instantiated because it is a parent class.
B `SportsCar` is an instance of `Car`.
C `SportsCar` can access the `model` attribute defined in `Car`.
D `SportsCar` cannot inherit methods from `Car`.
Show the answer

C · `SportsCar` can access the `model` attribute defined in `Car`.

`SportsCar` inherits from `Car`, allowing it to access the `model` attribute defined in the parent class through the `super()` function.

Q18. Evaluate the following code snippet and determine what will be the output when `my_car` is created: ```python class Car: def __init__(self, model): self.model = model class SportsCar(Car): def __init__(self, model, speed): super().__init__(model) self.speed = speed my_car = SportsCar('Ferrari', 200) print(my_car.model) ```

Advanced
A 'None'
B 'Car'
C 'Speed'
D 'Ferrari'
Show the answer

D · 'Ferrari'

The output will be 'Ferrari' because the `model` attribute is correctly initialized in the `Car` class and inherited by `SportsCar`.

Q19. Analyze the following class definitions and determine which statement best describes the relationship between `Animal` and `Dog`: ```python class Animal: def sound(self): return 'Some sound' class Dog(Animal): def sound(self): return 'Bark' ```

Advanced
A Both classes can have different implementations of the `sound` method.
B The `Animal` class is an instance of `Dog`.
C The `Dog` class does not inherit from `Animal`.
D The `Dog` class cannot override the `sound` method.
Show the answer

A · Both classes can have different implementations of the `sound` method.

The `Dog` class successfully overrides the `sound` method from the `Animal` class, allowing for different implementations while maintaining the same interface.

Q20. Consider the implications of encapsulation in the following class design: ```python class BankAccount: def __init__(self, balance): self.__balance = balance def deposit(self, amount): self.__balance += amount def get_balance(self): return self.__balance ``` What is the primary benefit of using the `__balance` attribute with double underscores?

Advanced
A It allows direct access to `balance` from outside the class.
B It makes the `get_balance` method unnecessary.
C It prevents any modification to the `balance` attribute.
D It restricts access to `__balance`, enhancing data security.
Show the answer

D · It restricts access to `__balance`, enhancing data security.

Using double underscores for `__balance` restricts access to the attribute from outside the class, enhancing data security by preventing unauthorized modifications.

Q21. Given the following code snippet, identify the polymorphic behavior demonstrated: ```python class Shape: def area(self): pass class Circle(Shape): def area(self, radius): return 3.14 * radius**2 class Square(Shape): def area(self, side): return side**2 ``` How does this design exemplify polymorphism?

Advanced
A The `area` method in `Shape` is abstract and cannot be called.
B Polymorphism is not demonstrated as `Shape` does not implement `area`.
C Both classes implement the same method name but with different parameters.
D Only `Circle` class has a valid implementation of `area`.
Show the answer

C · Both classes implement the same method name but with different parameters.

The design exemplifies polymorphism as both `Circle` and `Square` classes implement the `area` method, allowing different behaviors while using the same interface.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages