gs gs109 Python OOPs - Python Polymorphism - Quiz No.1
gs gs109 Python Quiz
This quiz belongs to book/course code gs gs109 Python of gs organization. We have 134 quizzes available related to the book/course Python. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Python OOPs. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Which of the following best describes polymorphism?
Ability of a class to derive members of another class as a part of its own definition
Means of bundling instance variables and methods in order to restrict access to certain class members
Focuses on variables and passing of variables to functions
Allows for objects of different types and behaviour to be treated as the same general type
Question 2: What is the biggest reason for the use of polymorphism?
It allows the programmer to think at a more abstract level
There is less program code to write
The program will have a more elegant design and will be easier to maintain and update
Program code takes up less space
Question 3: What is the use of duck typing?
More restriction on the type values that can be passed to a given method
No restriction on the type values that can be passed to a given method
Less restriction on the type values that can be passed to a given method
Makes the program code smaller
Question 4: What will be the output of the following Python code?
class A: def __str__(self): return '1' class B(A): def __init__(self): super().__init__() class C(B): def __init__(self): super().__init__() def main(): obj1 = B() obj2 = A() obj3 = C() print(obj1, obj2,obj3) main()
1 1 1
1 2 3
‘1’ ‘1’ ‘1’
An exception is thrown
Question 10: What will be the output of the following Python code?
class Demo: def check(self): return " Demo's check " def display(self): print(self.check()) class Demo_Derived(Demo): def check(self): return " Derived's check " Demo().display() Demo_Derived().display()
Demo’s check Derived’s check
Demo’s check Demo’s check
Derived’s check Demo’s check
Syntax error