wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz4-OOP-MakScie

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

Which module in Python is used to create abstract classes?

a)

abstractmodule

b)

abc

c)

absclass

d)

interface

2.

What does @abstractmethod do in Python?

a)

Makes a method private

b)

Forces subclasses to override the method

c)

Makes the method static

d)

Deletes the method

3.

What happens if a subclass does NOT implement all abstract methods from its parent abstract class?

a)

Nothing

b)

It becomes an abstract class

c)

Python automatically adds default implementations

d)

It raises a runtime error

4.

Which statement is TRUE about abstract classes?

a)

They can be instantiated

b)

They cannot contain implemented methods

c)

They are created using the ABC class

d)

They replace the need for inheritance

5.

An interface in Python is typically implemented using:

a)

interface keyword

b)

ABC with only abstract methods

c)

Regular classes

d)

Decorators only

6.

The purpose of using abstract classes is:

a)

To provide a base class with common functionality that cannot be instantiated directly.

b)

To allow multiple inheritance in all programming languages.

c)

To create classes that can be instantiated without any methods.

d)

To ensure all methods in the class are private.

7.

The main purpose of using abstract classes in Python is:

a)

To hide methods

b)

To enforce method structure in subclasses

c)

To improve performance

d)

To create global variables

8.

Which of the following can an abstract class contain?

a)

Only abstract methods

b)

Only concrete methods

c)

Both abstract and concrete methods

d)

No methods at all

9.

A class inheriting from an ABC must:

a)

Call super().__init__()

b)

Use @abstractclass

c)

Implement all abstract methods

d)

Be declared final

10.

In Python, an abstract method:

a)

Must have no body

b)

Can have a body

c)

Must be static

d)

Must be private

11.

What happens if you try to instantiate an abstract class?

a)

It works normally

b)

Python issues a warning

c)

TypeError is raised

d)

The object contains null methods

12.

Polymorphism allows:

a)

Objects taking multiple forms

b)

Classes to inherit from two parents

13.

Which function in Python is MOST commonly used to demonstrate polymorphism?

a)

print()

b)

open()

c)

len()

d)

input()

14.

Polymorphism works best when:

a)

Classes have unrelated methods

b)

Classes share method names

c)

Classes have no inheritance

d)

Functions do not accept arguments

15.

Duck typing in Python means:

a)

Only classes named "Duck" can be used

b)

Type checking is strict

c)

An object’s behavior determines its type

d)

Python forces type declarations

16.

Which is an example of polymorphism?

a)

Same function name behaves differently across classes

b)

A class with only one method

c)

A function without arguments

d)

Private variables

17.

Method overriding occurs when:

a)

Two methods have different names

b)

A child class redefines a parent class method

c)

Methods have different number of arguments

18.

Which keyword is used to call a parent method inside an overridden method?

a)

parent

b)

super

c)

override

d)

base

19.

Method overriding is mainly used for:

a)

Increasing execution speed

b)

Providing specific implementation in subclasses

c)

Creating private variables

d)

Adding new parameters

20.

To override a method in Python, methods must have:

a)

Same name and parameters

b)

Different names

c)

Different return types

d)

More parameters

21.

Which of the following is NOT true about method overriding?

a)

It supports runtime polymorphism

b)

It lets subclasses define specific behavior

c)

It occurs across different classes

d)

It requires multiple inheritance

22.

Dynamic binding occurs:

a)

When the method to call is decided at compile time

b)

When method resolution happens at runtime

c)

During class definition

23.

Python supports dynamic binding because:

a)

It is statically typed

b)

Types are checked during compilation

c)

Methods are resolved using object type at runtime

d)

Classes cannot be modified

24.

Dynamic binding is essential for:

a)

Polymorphism

b)

Encapsulation

c)

Static variables

d)

Static typing

25.

Dynamic binding helps Python choose:

a)

Which class to inherit from

b)

Which variable to delete

c)

Which method to call at runtime

d)

What package to import

26.

Which Python feature relies heavily on dynamic binding?

a)

Abstract classes

b)

Method overriding

c)

Loops

d)

Tuples

27.

Code-Based Questions
26. What is the output of the following code?

class A:
    def show(self):
        return "A"

What will be the result of calling A().show()?

a)

A

b)

show

c)

self

d)

None

28.

class A:

    def show(self):

        return "A"

 

class B(A):

    pass

 

obj = B()

print(obj.show())

What is the output?

a)

Error

b)

A

c)

B

d)

None

29.

What is the output?

from abc import ABC, abstractmethod

 

class Animal(ABC):

    @abstractmethod

    def sound(self):

        pass

 

class Dog(Animal):

    def sound(self):

        return "Bark"

 

print(Dog().sound())

a)

Error

b)

Bark

c)

None

d)

Abstract

30.

What is the output?

class A:

    def show(self):

        return "A"

 

class B(A):

    def show(self):

        return "B"

 

class C(B):

    pass

 

obj = C()

print(obj.show())

a)

A

b)

B

c)

C

d)

Error

31.

class A(ABC): pass What is the correct answer?

a)

A. Error: ABC not imported

b)

B. Works normally

c)

C. Automatically creates abstract method

d)

D. Cannot subclass

32.

What is true about ABCs in Python?

a)

All methods must be abstract

b)

Abstract classes must inherit from ABC

c)

Abstract methods must be static

d)

ABCs cannot contain variables

33.

What will be the result?

class X:

    def show(self):

        return "X"

 

class Y:

    def show(self):

        return "Y"

 

def display(obj):

    print(obj.show())

 

display(Y())

a)

Error

b)

X

c)

Y

d)

NONE

34.

What does this demonstrate?

class A:

    def test(self):

        return "A"

 

class B(A):

    def test(self):

        return "B"

a)

Method overloading

b)

Method overriding

c)

No polymorphism

d)

Interfaces

35.

What concept is shown here?

def func(obj):

    obj.run()

a)

Static binding

b)

Duck typing

c)

Encapsulation

d)

Overloading

36.

Which is TRUE about dynamic binding?

a)

Happens only in compiled languages

b)

Python resolves methods during execution

c)

Python forbids it

37.

What is needed to create an interface-like class in Python?

a)

Use multiple inheritance

b)

Use ABC with only abstract methods

c)

Use static methods

d)

Use decorators only

38.

What is the output?

class A:

    def str(self):

        return "A"

 

class B(A):

    pass

 

print(B())

a)

Error

b)

B

c)

A

d)

None

39.

Runtime polymorphism is achieved mainly through:

a)

Method overloading

b)

Method overriding

c)

Class variables

d)

Private attributes

40.

Abstract classes enforce:

a)

Security

b)

Method naming rules

c)

Common interface for subclasses

d)

Faster execution