An example of polymorphism would be which of the following: a) overloading b) instantiating c) overriding d) both a and c are correct?

The correct answer is d) both a and c are correct.

Polymorphism is a core concept in object-oriented programming that allows objects to be treated as instances of their parent class. It primarily manifests through method overloading and method overriding. Method overloading (a) allows multiple methods to have the same name but different parameters within the same class, thus providing different implementations based on the input. Method overriding (c), on the other hand, occurs when a subclass provides a specific implementation of a method that is already defined in its superclass. Both techniques illustrate how the same interface can be used for different underlying forms (data types). Therefore, both option a and c correctly exemplify polymorphism, making d the comprehensive answer.

More Related Questions