ITPEC FE Morning October 2023 Question 47
Which of the following is the most appropriate feature of polymorphism in object-oriented programming?
Explanation
The same message is interpreted differently by different classes of objects — that is polymorphism.
In object-oriented programming, several classes can implement the same method name in their own way. The sender only issues the message, for example draw(, and each receiving object (a Circle, a Square) runs its own version. The caller need not know the concrete class, so new classes can be added without changing the calling code. Overriding a superclass method in subclasses is the usual way to achieve this.
Answer (d)
Why not others:
- •(a) — defining new classes by reusing existing classes as their basis describes inheritance
- •(b) — publishing only what a user of the module needs describes information hiding
- •(c) — combining processes and data into a single object describes encapsulation
Key rule: Inheritance reuses a class, encapsulation bundles data with methods, information hiding limits what is visible, and polymorphism lets one message produce class-specific behaviour.
System Development Technology · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.