asked 155k views
4 votes
Which two techniques can be used to provide polymorphic behavior? Choose two A. Extending a class and adding a new method B. mplementing two interface in same class C. Extending the class and overriding a existing method D. Implementing a interfaces with several different classes

1 Answer

7 votes

The two techniques can be used to provide polymorphic behavior are;

B. Implementing two interface in same class

C. Extending the class and overriding a existing method

Polymorphism in object-oriented programming involves using inheritance by extending a class and overriding methods from the parent class in the child class. This allows different classes to have their own implementation of the same method, enabling polymorphic behavior.

By implementing multiple interfaces in a class, it can inherit different behaviors and methods from each interface, allowing the class to exhibit polymorphic behavior by adhering to multiple contracts specified by the interfaces.

answered
User Adam Heeg
by
8.0k points