Classes And Objects In Python — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Classes And Objects In Python — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
22
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
27 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
22
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress | 0/22 answered
✓ 0 correct
✗ 0 wrong
0% score
🎉 Set complete! All 22 questions answered.
Question 1 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Question 2 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class test: def __init__(self,a): self.a=a def display(self): print(self.a) obj=test() obj.display()
Question 3 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class Demo: def __init__(self): pass def test(self): print(__name__) obj = Demo() obj.test()
Question 4 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Special methods need to be explicitly called during object creation.
Question 5 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a class method?
Question 6 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the super() function in Python classes?
Question 7 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class change: def __init__(self, x, y, z): self.a = x + y + z x = change(1,2,3) y = getattr(x, 'a') setattr(x, 'a', y+1) print(x.a)
Question 8 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following Python code creates an empty class?
Question 9 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class test: def __init__(self): self.variable = 'Old' self.Change(self.variable) def Change(self, var): var = 'New' obj=test() print(obj.variable)
Question 10 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Is the following Python code correct? >>> class A: def __init__(self,b): self.b=b def display(self): print(self.b) >>> obj=A("Hello") >>> del obj
Question 11 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?
Question 12 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class fruits: def __init__(self, price): self.price = price obj=fruits(50) obj.quantity=10 obj.bags=2 print(obj.quantity+len(obj.__dict__))
Question 13 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is hasattr(obj,name) used for?
Question 14 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class stud: ‘Base class for all students’ 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) print(student.__doc__)
Question 15 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: class Parent: x = 10 class Child(Parent): pass obj = Child() print(obj.x)
Question 16 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can you check if an object belongs to a specific class in Python?
Question 17 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
__del__ method is used to destroy instances of a class.
Question 18 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can you create a static variable in a Python class?
Question 19 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>> class demo(): def __repr__(self): return '__repr__ built-in function called' def __str__(self): return '__str__ built-in function called' >>> s=demo() >>> print(s)
Question 20 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the @property decorator in Python classes?
Question 21 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class test: def __init__(self,a="Hello World"): self.a=a def display(self): print(self.a) obj=test() obj.display()
Question 22 of 22
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is delattr(obj,name) used for?
✓ Link copied to clipboard
Continue Your Practice
Next Practice Set → Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡 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.