wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

IT 403 - Quiz 2

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which operator is responsible for overloading the + operator in Python?

a)

__add__

b)

__plus__

c)

__concat__

d)

__sum__

2.

What will be the output of this code?

a)

A

b)

B

c)

C

d)

Error

3.

Which of the following is not a principle of Object-Oriented Programming?

a)

Inheritance

b)

Encapsulation

c)

Composition

d)

Abstraction

4.

Which method is called when an object is deleted in Python?

a)

__delete__

b)

__destruct__

c)

__del__

d)

__destroy__

5.

What happens when a method in a child class has the same name as a method in the parent class?

a)

The child method is ignored

b)

The parent method is ignored

c)

The child method overrides the parent method

d)

Python throws an error

6.

What is the default return value of a Python function or method that doesn’t explicitly return a value?

a)

None

b)

0

c)

True

d)

False

7.

Which of the following is NOT a dunder method in Python?

a)

__add__

b)

__str__

c)

__init__

d)

__destruct__

8.

Which method would you override to customize the string representation of an object?

a)

__str__

b)

__repr__

c)

__print__

d)

__call__

9.

Which of the following best describes method overriding in Python?

a)

Defining a method in a subclass that has the same name and parameters as a method in the superclass.

b)

Defining multiple methods in a class with the same name but different parameters.

c)

Using the super() function to access parent class methods.

d)

Redefining a class's constructor to initialize attributes.

10.

In Python, which of the following attributes of a class is shared across all instances?

a)

Instance attributes

b)

Class attributes

c)

Private attributes

d)

Public attributes

11.

Which method is responsible for creating an instance of a class in Python?

a)

__new__

b)

__init__

c)

__construct__

d)

__str__

12.

What is the output of the following code?

a)

Parent

b)

Child

c)

None

d)

Error

13.

What is the correct way to declare a private attribute in Python?

a)

self._attribute

b)

self.attribute

c)

self.__attribute

d)

private self.attribute

14.

Which of the following Python features allows for method overriding in subclasses?

a)

Encapsulation

b)

Inheritance

c)

Abstraction

d)

Polymorphism

15.

How do you create an object of the class Student in Python?

a)

Student s = new Student()

b)

s = new Student()

c)

s = Student()

d)

s = create Student()