Class 11 Computer Science · Chapter 2 · Test 5
OOP, Exceptions and Files
39 MCQs Covers classes, objects, init, self, access modifiers and exception handling. Also covers file modes, with open, unit testing and debugging
39 questions · 35 min · 39 marks
Want to try first? Take the free Computer Science test: SDLC and Waterfall Model
Sample questions
The first 5 of 39. Try each one, then tap to see the answer.
Question 1
What is a class in Python?
- AA set of if statements
- BA blueprint to create objects
- CA loop
- DA function
Show answerHide answer
Answer: B
A class defines the attributes and methods that its objects will have.
Question 2
Which method initializes a new object in Python?
- Acreate
- Bstart
- Cnew
- D__init__
Show answerHide answer
Answer: D
__init__() is the constructor and runs automatically when an object is created.
Question 3
What does self refer to in a class?
- AThe object itself
- BThe current module
- CA function
- DA class variable
Show answerHide answer
Answer: A
self refers to the current object and is used to access its attributes and methods.
Question 4
Which of the following defines inheritance?
- AReusing variables
- BAccessing files
- COne class taking properties of another
- DWriting the same function again
Show answerHide answer
Answer: C
In inheritance a child class gets the properties and methods of a parent class.
Question 5
What is exception handling used for?
- AMaking code faster
- BManaging errors
- CFixing bugs
- DSaving files
Show answerHide answer
Answer: B
It catches errors at run time so the program does not crash.
More tests in Python Programming
Practise with a free account
Save your scores, see which chapters need work, and keep a notebook of every question you got wrong.