GATE DA Python OOP, Modules & Exception Handling | Set 1

Questions 26-30 of 100

0% completed (0/100 answered)
Your score 0/100 0 answered
Correct 0 Incorrect 0 Unanswered 100 Accuracy 0%

Question 26

MCQ · Single Correct 1 mark
PYTHON
What is the output of the following Python code?
class Parent:
 def show(self):
 return 'Parent'
class Child(Parent):
 def show(self):
 return 'Child:' + super().show()

$c = Child()
print(c.show())$

Answers for question 26

Question 27

NAT · Numerical Answer 1 mark
PYTHON
What is the output of the following code?
class A:
 def __init__{self}:
 self.x = 10
class B(A):
 def __init__{self}:
 super().__init__()
 self.x += 5

$b = B()
print(b.x)$

Answers for question 27

Question 28

MCQ · Single Correct 1 mark
PYTHON
Consider the following Diamond Inheritance structure:
class A:
 def m(self):
 return 'A'
class B(A):
 def m(self):
 return 'B' + super().m()
class C(A):
 def m(self):
 return 'C' + super().m()
class D(B, C):
 def m(self):
 return 'D' + super().m()

print(D().m())

Answers for question 28

Question 29

NAT · Numerical Answer 1 mark
PYTHON
Evaluate the output:
class A:
 val = 1
class B(A):
 val = 2
class C(A):
 val = 3
class D(B, C):
 pass

print(D.val)

Answers for question 29

Question 30

MCQ · Single Correct 1 mark

Which algorithm does Python 3 use to compute Method Resolution Order (MRO) for multiple inheritance?

Answers for question 30
Scroll to Top