Which of the following concepts allows an object to take many forms in…

2025

Which of the following concepts allows an object to take many forms in object-oriented programming?

  1. A.

    Polymorphism

  2. B.

    Abstraction

  3. C.

    Encapsulation

  4. D.

    Inheritance

Attempted by 97 students.

Show answer & explanation

Correct answer: A

In Object-Oriented Programming, Polymorphism allows a parent class reference variable to hold a reference to any child class object. This means a single variable can dynamically take different shapes at runtime.

There are two primary ways polymorphism manifests in programming:

  1. Runtime Polymorphism (Method Overriding): Imagine a parent class named Animal with a method called makeSound(). Two child classes, Dog and Cat, inherit from Animal but override makeSound() to print "Bark" and "Meow" respectively.

    If you create an array of Animal objects containing both a dog and a cat, you can loop through the array and call .makeSound() on each element. Even though you are interacting with them through a generic Animal reference, the system resolves the method at runtime based on the actual object type, producing different results.

  2. Compile-time Polymorphism (Method Overloading):
    This allows a single class to have multiple methods with the exact same name but different input parameter configurations (different signatures). The compiler determines which specific implementation to invoke based on the arguments provided during the function call.

Explore the full course: Rssb Senior Computer Instructor