Font size
WorksheetsIT 403 - Quiz 2
Total questions: 15
Worksheet time: 8mins
Which operator is responsible for overloading the + operator in Python?
__add__
__plus__
__concat__
__sum__
What will be the output of this code?
A
B
C
Error
Which of the following is not a principle of Object-Oriented Programming?
Inheritance
Encapsulation
Composition
Abstraction
Which method is called when an object is deleted in Python?
__delete__
__destruct__
__del__
__destroy__
What happens when a method in a child class has the same name as a method in the parent class?
The child method is ignored
The parent method is ignored
The child method overrides the parent method
Python throws an error
What is the default return value of a Python function or method that doesn’t explicitly return a value?
None
0
True
False
Which of the following is NOT a dunder method in Python?
__add__
__str__
__init__
__destruct__
Which method would you override to customize the string representation of an object?
__str__
__repr__
__print__
__call__
Which of the following best describes method overriding in Python?
Defining a method in a subclass that has the same name and parameters as a method in the superclass.
Defining multiple methods in a class with the same name but different parameters.
Using the super() function to access parent class methods.
Redefining a class's constructor to initialize attributes.
In Python, which of the following attributes of a class is shared across all instances?
Instance attributes
Class attributes
Private attributes
Public attributes
Which method is responsible for creating an instance of a class in Python?
__new__
__init__
__construct__
__str__
What is the output of the following code?
Parent
Child
None
Error
What is the correct way to declare a private attribute in Python?
self._attribute
self.attribute
self.__attribute
private self.attribute
Which of the following Python features allows for method overriding in subclasses?
Encapsulation
Inheritance
Abstraction
Polymorphism
How do you create an object of the class Student in Python?
Student s = new Student()
s = new Student()
s = Student()
s = create Student()
