wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

OOP-Q1

Total questions: 10

Worksheet time: 3mins

Name
Class
Date
1.

What does a class represent in OOP?

a)

A specific instance of an object

b)

A blueprint for creating objects

c)

A method inside an object

d)

A variable inside an object

2.

Which keyword is used to define a class in Python?

a)

`object`

b)

`self`

c)

`class`

d)

`define`

3.

Which of the following is an instance of the `Car` class?

a)

Car("Toyota")

b)

class Car: pass

c)

def Car(): pass

d)

"Car"

4.

What is the purpose of the `__init__` method in Python?

a)

It is a destructor for objects.

b)

It initializes the attributes of a class.

c)

It creates a new instance of a class.

d)

It is used to create private variables.

5.

Identify the correct syntax to access an attribute of an object.

a)

dog1[name]

b)

dog1::name

c)

dog1.name

d)

dog1->name

6.

What will the following code output?

a)

`Hello, Alice!`

b)

Hello, {self.name}!

c)

greet()

d)

None

7.

Which statement about inheritance in Python is correct?

a)

A class can inherit from multiple parent classes.

b)

Only one class can be inherited at a time.

c)

Inheritance is not possible in Python.

d)

Parent classes cannot have methods.

8.

What will happen if you run this code?

a)

An object is created without any issues.

b)

The program will throw a TypeError.

c)

The program will throw a NameError.

d)

The program will throw an AttributeError.

9.

What does the self keyword refer to?

a)

The class itself

b)

The instance of the class inside itself

c)

A static method

d)

The parent class

10.

What is the output of the following code?

a)

Error

b)

This is a Shape

c)

Circle

d)

This is a Circle