OOPs in Python

OOPs in Python

University

•

20 Qs

quiz-placeholder

Similar activities

Object Oriented Programming Assessment 1

Object Oriented Programming Assessment 1

University

•

15 Qs

PythonProgramming

PythonProgramming

University

•

15 Qs

Pengantar Teknologi Informasi 8

Pengantar Teknologi Informasi 8

University

•

17 Qs

QUIZ TENGAH SEMESTER

QUIZ TENGAH SEMESTER

University

•

20 Qs

C++ Assesment 1

C++ Assesment 1

University

•

20 Qs

DCN5511: Chapter 5 - 7

DCN5511: Chapter 5 - 7

University

•

15 Qs

Revision : Chapter 1

Revision : Chapter 1

University

•

19 Qs

PROGRAMMING CAMP

PROGRAMMING CAMP

University

•

20 Qs

OOPs in Python

OOPs in Python

Assessment

Quiz

•

Computers

•

University

•

Practice Problem

•

Medium

Created by

Anik Acharjee

Used 53+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code?

class A:

    def init(self):

        self.x = 1

class B(A):

    def init(self):

        super().__init__()

        self.y = 2

b = B()

print(b.x, b.y)

1 2

Error

2 1

None

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code?

class Animal:

    def speak(self):

        print("Animal speaks")

class Dog(Animal):

    def speak(self):

        print("Dog barks")

d = Dog()

d.speak()

Animal speaks

Dog barks

Error

None

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is true about multiple inheritance in Python?

Python does not support multiple inheritance

A class can inherit from only two parent classes

A class can inherit from multiple parent classes

Multiple inheritance is only possible with abstract classes

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code?

class A:

    def init(self):

        self.x = 1

    def method(self):

        print("Method of class A")

class B(A):

    def method(self):

        super().method()

        print("Method of class B")

b = B()

b.method()

Method of class A

Method of class B

Method of class A

   Method of class B

Error

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is used to implement abstraction in Python?

@abstractmethod decorator

abstract keyword

interface keyword

virtual keyword

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code?

class A:

    x = 1

a1 = A()

a2 = A()

a1.x = 2

print(a1.x, a2.x, A.x)

2 1 1

2 2 2

2 1 2

Error

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is true about the `__init__` method in Python?

It must return a value

It is called automatically when a class is instantiated

It can only have one parameter

It is optional in all classes

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers