OOPs in Python

Quiz
•
Computers
•
University
•
Medium
Anik Acharjee
Used 45+ times
FREE Resource
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
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
Behavioral Design Patterns

Quiz
•
University
15 questions
AITT LAB QUIZ 1

Quiz
•
University
15 questions
Exploring Python Fundamentals

Quiz
•
12th Grade - University
20 questions
JAVA Basics Quiz

Quiz
•
University
20 questions
Mastering Python Loops and Functions

Quiz
•
10th Grade - University
20 questions
Quiz 2 PBO

Quiz
•
University
18 questions
JQuery Quiz

Quiz
•
University
15 questions
CS 2nd Semester Mid-Term

Quiz
•
10th Grade - University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University