Python OOPs quiz

Last Updated :
Discuss
Comments

Question 1

What is the primary goal of Object-Oriented Programming (OOP)?

  • Code reusability and modularity

  • Efficient memory utilization

  • Procedural abstraction

  • Dynamic typing

Question 2

In Python, what is a class?

  • A function

  • A module

  • A code block

  • A blueprint for creating objects

Question 3

What is an instance variable in a class?

  • A variable shared among all instances of a class

  • A variable defined outside the class

  • A variable specific to an instance of a class

  • A variable used for method overloading

Question 4

What is encapsulation in OOP?

  • The process of converting a class into a module

  • Combining multiple classes into a single class

  • Restricting access to certain components of an object and hiding the implementation details

  • Creating a new instance of a class

Question 5

What is the difference between a class variable and an instance variable?

  • Class variables are specific to instances, while instance variables are shared among all instances.

  • Class variables are defined outside the class, while instance variables are defined inside the class.

  • Class variables are shared among all instances, while instance variables are specific to each instance.

  • Class variables are used for method overloading, while instance variables are used for method overriding.

Question 6

Inheritance in OOP allows a class to:

  • Combine multiple classes into one

  • Define multiple methods with the same name

  • Inherit properties and behaviors from a superclass

  • Restrict access to certain components of an object

Question 7

What is polymorphism in OOP?

  • Combining multiple classes into one

  • Restricting access to certain components of an object

  • Defining multiple methods with the same name in a class

  • Providing a single interface for different types

Question 8

Which keyword is used to achieve method overloading in Python?

  • overload

  • method

  • override

  • Python does not support method overloading

Question 9

What is the primary purpose of abstraction in OOP?

  • Combining multiple classes into one

  • Restricting access to certain components of an object

  • Defining multiple methods with the same name in a class

  • Simplifying complex systems by modeling classes based on their essential characteristics

Question 10

What is the term for the process of creating a new class based on an existing class?

  • Encapsulation

  • Abstraction

  • Inheritance

  • Polymorphism

There are 25 questions to complete.

Take a part in the ongoing discussion