Skip to main content

Classes And Objects In Python — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Classes And Objects In Python — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What is the output of the following code: class Parent: def show(self): print('Parent method') class Child(Parent): pass obj = Child() obj.show()

Question 2 of 40
★ FPSC ★ PPSC

What is the output of the following code: class MyClass: count = 0 def init(self): MyClass.count += 1 obj1 = MyClass() obj2 = MyClass() print(obj1.count)

Question 3 of 40
★ FPSC ★ PPSC

What is a class in Python?

Question 4 of 40
★ FPSC ★ PPSC

How do you define a class in Python?

Question 5 of 40
★ FPSC ★ PPSC

What are objects in Python?

Question 6 of 40
★ FPSC ★ PPSC

How do you create an object of a class in Python?

Question 7 of 40
★ FPSC ★ PPSC

What is the purpose of the self parameter in Python methods?

Question 8 of 40
★ FPSC ★ PPSC

How can you define a method in a Python class?

Question 9 of 40
★ FPSC ★ PPSC

How can you delete an attribute of an object in Python?

Question 10 of 40
★ FPSC ★ PPSC

What is encapsulation in Python classes?

Question 11 of 40
★ FPSC ★ PPSC

What is the purpose of the @staticmethod decorator in Python classes?

Question 12 of 40
★ FPSC ★ PPSC

What is the __init__ method used for in Python classes?

Question 13 of 40
★ FPSC ★ PPSC

How can you access the attributes of an object in Python?

Question 14 of 40
★ FPSC ★ PPSC

How can you inherit a class in Python?

Question 15 of 40
★ FPSC ★ PPSC

What is method overriding in Python classes?

Question 16 of 40
★ FPSC ★ PPSC

What is the purpose of the __str__ method in Python classes?

Question 17 of 40
★ FPSC ★ PPSC

What is the purpose of the __del__ method in Python classes?

Question 18 of 40
★ FPSC ★ PPSC

Which function is called when the following Python code is executed? f = foo() format(f)

Question 19 of 40
★ FPSC ★ PPSC

Which operator is overloaded by __invert__()?

Question 20 of 40
★ FPSC ★ PPSC

Which operator is overloaded by __lg__()?

Question 21 of 40
★ FPSC ★ PPSC

Which operator is overloaded by the __or__() function?

Question 22 of 40
★ FPSC ★ PPSC

What is Instantiation in terms of OOP terminology?

Question 23 of 40
★ FPSC ★ PPSC

The assignment of more than one function to a particular operator is . . . . . . . .

Question 24 of 40
★ FPSC ★ PPSC

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

Question 25 of 40
★ FPSC ★ PPSC

How can you access a class variable in Python?

Question 26 of 40
★ FPSC ★ PPSC

. . . . . . . . represents an entity in the real world with its identity and behaviour.

Question 27 of 40
★ FPSC ★ PPSC

. . . . . . . . is used to create an object.

Question 28 of 40
★ FPSC ★ PPSC

What are the methods which begin and end with two underscore characters called?

Question 29 of 40
★ FPSC ★ PPSC

What is setattr() used for?

Question 30 of 40
★ FPSC ★ PPSC

What is getattr() used for?

Question 31 of 40
★ FPSC ★ PPSC

What is the output of the following code: class MyClass: x = 5 obj = MyClass() print(obj.x)

Question 32 of 40
★ FPSC ★ PPSC

Is the following Python code valid? class B(object): def first(self): print("First method called") def second(): print("Second method called") ob = B() B.first(ob)

Question 33 of 40
★ FPSC ★ PPSC

Which function overloads the == operator?

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? class stud: def __init__(self, roll_no, grade): self.roll_no = roll_no self.grade = grade def display (self): print("Roll no : ", self.roll_no, ", Grade: ", self.grade) stud1 = stud(34, 'S') stud1.age=7 print(hasattr(stud1, 'age'))

Question 35 of 40
★ FPSC ★ PPSC

What does print(Test.__name__) display (assuming Test is the name of the class)?

Question 36 of 40
★ FPSC ★ PPSC

What is a constructor in Python classes?

Question 37 of 40
★ FPSC ★ PPSC

Which of the following Python code will print True? a = foo(2) b = foo(3) print(a < b)

Question 38 of 40
★ FPSC ★ PPSC

What is the purpose of the @classmethod decorator in Python classes?

Question 39 of 40
★ FPSC ★ PPSC

What is the output of the following code: class Parent: def init(self): print('Parent constructor') class Child(Parent): def init(self): print('Child constructor') obj = Child()

Question 40 of 40
★ FPSC ★ PPSC

How can you create a private attribute in a Python class?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →