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

Questions 31-35 of 100

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

Question 31

NAT · Numerical Answer 1 mark
PYTHON
Consider the code:
class A:
    def __init__{self}:
        self.a = 1
class B:
    def __init__{self}:
        self.b = 2
class C(A, B):
    def __init__{self}:
        A.__init__{self}
        B.__init__{self}
        self.c = 3

obj = C()
print(obj.a + obj.b + obj.c)

Answers for question 31

Question 32

MCQ · Single Correct 1 mark
PYTHON
What is the output of the following Python code?
class Base:
    def __init__{self}:
        print('Base', end=' ')
class Sub(Base):
    def __init__{self}:
        print('Sub', end=' ')

s = Sub()

Answers for question 32

Question 33

NAT · Numerical Answer 1 mark
PYTHON
What is the output of the following code?
class A:
    def foo(self):
        return 10
class B(A):
    def foo(self):
        return super().foo() * 2
class C(B):
    def foo(self):
        return super().foo() + 5

print(C().foo())

Answers for question 33

Question 34

MCQ · Single Correct 1 mark

What is the result of checking issubclass(bool, int) in Python?

Answers for question 34

Question 35

NAT · Numerical Answer 1 mark
PYTHON
Consider:
class X:
    pass
class Y(X):
    pass
class Z(Y):
    pass

obj = Z()
print(1 if isinstance(obj, X) else 0)

Answers for question 35
Scroll to Top