Question

    Which of the following statements best describes

    polymorphism in object-oriented programming?
    A The ability to bind a function to more than one object during compile-time only Correct Answer Incorrect Answer
    B The ability of different objects to respond uniquely to the same method call Correct Answer Incorrect Answer
    C The ability of a class to inherit multiple constructors from its parent classes Correct Answer Incorrect Answer
    D The capability of an interface to implement multiple classes simultaneously Correct Answer Incorrect Answer
    E The encapsulation of multiple methods into a single object for reuse. Correct Answer Incorrect Answer

    Solution

    Polymorphism is a core concept of Object-Oriented Programming (OOP) that allows objects to respond to the same method call in different ways based on their type. This is particularly useful in scenarios where a parent class defines a method, and child classes override this method to provide specific behavior. Polymorphism can occur in two forms:

    • Compile-Time Polymorphism (Static) : Achieved using method overloading.
    • Run-Time Polymorphism (Dynamic) : Achieved using method overriding, where the method to be invoked is determined during runtime.
    For instance, if a parent class Shape has a method draw() , subclasses like Circle and Square can provide their own implementation of draw() . When an object of type Shape calls draw() , the method corresponding to its actual subclass is invoked. This ensures flexibility and extensibility in code design. Why Other Options Are Wrong Option A : "The ability to bind a function to more than one object during compile-time only." This incorrectly limits polymorphism to compile-time behavior. While method overloading is a compile-time polymorphism feature, the definition of polymorphism extends beyond this to include runtime behavior via method overriding. Option C : "The ability of a class to inherit multiple constructors from its parent classes." Constructors are not inherited in OOP. Child classes have their own constructors, though they may call the parent class's constructor explicitly. This statement misunderstands the concept of inheritance and constructor behavior. Option D : "The capability of an interface to implement multiple classes simultaneously." This is inaccurate as interfaces cannot implement classes. Instead, interfaces can be implemented by multiple classes . This statement reflects a misunderstanding of how interfaces function in OOP. Option E : "The encapsulation of multiple methods into a single object for reuse." This describes encapsulation or method grouping but does not define polymorphism. Encapsulation ensures data and behavior are bundled within a single unit but is unrelated to the ability to respond to method calls in varied ways.

    Practice Next