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

Questions 41-45 of 100

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

Question 41

NAT · Numerical Answer 1 mark
PYTHON
What is the output?
class P:
    x = 5
class C(P):
    pass

c = C()
C.x = 15
print(c.x + P.x)

Answers for question 41

Question 42

MCQ · Single Correct 1 mark

What happens when super() is called without arguments inside an instance method in Python 3?

Answers for question 42

Question 43

NAT · Numerical Answer 1 mark
PYTHON
Evaluate the output:
class A:
    def f(self):
        return 'A'
class B(A):
    def f(self):
        return 'B'

a = B()
print(1 if A.f(a) == 'A' else 0)

Answers for question 43

Question 44

MCQ · Single Correct 1 mark

Which of the following describes Method Overriding in Python?

Answers for question 44

Question 45

NAT · Numerical Answer 1 mark
PYTHON
What is the output of:
class A:
    def __init__{self}:
        self.a = 1
class B(A):
    def __init__{self}:
        self.b = 2

b = B()
print(getattr(b, 'a', 0) + getattr(b, 'b', 0))

Answers for question 45
Scroll to Top