Exercise: Polymorphism
Questions for: Polymorphism
Which of the following statements about method overloading in Python is correct?
A:
Python supports method overloading with different return types
B:
Python supports method overloading with the same method name but different parameters
C:
Method overloading is not allowed in Python
D:
Python supports method overloading by explicitly specifying the data type of parameters
Answer: C
Python does not support method overloading in the traditional sense as it is done in languages like Java. Methods with the same name in a class will override each other.
In Python, what is polymorphism?
A:
The ability of a class to inherit from multiple classes
B:
The ability of a function to take different types of arguments
C:
The ability of an object to take on multiple forms or types
D:
The ability to create instances of a class
Answer: C
Polymorphism in Python refers to the ability of an object to take on multiple forms or types.
Discuss About this Question.
Which of the following are necessary for Run-time Polymorphism?
- The overridden base method must be virtual, abstract or override.
- Both the override method and the virtual method must have the same access level modifier.
- An override declaration can change the accessibility of the virtual method.
- An abstract inherited property cannot be overridden in a derived class.
- An abstract method is implicitly a virtual method.
A:
1, 3
B:
1, 2, 5
C:
2, 3, 4
D:
4 only
Answer: B
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following can be declared as a virtual in a class?
- Methods
- Properties
- Events
- Fields
- Static fields
A:
1, 2, 3
B:
3, 5
C:
2, 4
D:
2, 3, 5
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
In order for an instance of a derived class to completely take over a class member from a base class, the base class has to declare that member as
A:
new
B:
base
C:
virtual
D:
overrides
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.