What is Polymorphism?

what is polymorphism?

Asked on January 18, 2019 in Java.
Add Comment

  • 5 Answer(s)

    polymorphism means many forms.

    A single object can refer the super class or sub-class depending on the reference type which is called polymorphism.


    1 Public class Manipulation(){ //Super class
    2 public void add(){
    3 }
    4 }
    5 public class Addition extends Manipulation(){ // Sub class
    6 public void add(){
    7 }
    8 public static void main(String args[]){
    9 Manipulation addition = new Addition();//Manipulation is reference type and Addition is reference type
    10 addition.add();
    11 }
    12 }

    Using Manipulation reference type we can call the Addition class “add()” method. This ability is known as Polymorphism.

    Polymorphism is applicable for overriding and not for overloading.

    Answered on January 18, 2019.
    Add Comment

    Polymorphism is an object-oriented programming concept that refers to the ability of a variable, function or object to take on multiple forms. A language that features polymorphism allows developers to program in the general rather than program in the specific.

    Answered on January 27, 2019.
    Add Comment


    The word polymorphism is used in various contexts and describes situations in which something occurs in several different forms. In computer science, it describes the concept that objects of different types can be accessed through the same interface. Each type can provide its own, independent implementation of this interface. It is one of the core concepts of object-oriented programming (OOP).



    Let us look at an example.

    public interface Vegetarian{}
    public class Animal{}
    public class Deer extends Animal implements Vegetarian{}

    Now, the Deer class is considered to be polymorphic since this has multiple inheritance. Following are true for the above examples −

    • A Deer IS-A Animal
    • A Deer IS-A Vegetarian
    • A Deer IS-A Deer
    • A Deer IS-A Object

    When we apply the reference variable facts to a Deer object reference, the following declarations are legal −


    Deer d = new Deer();
    Animal a = d;
    Vegetarian v = d;
    Object o = d;

    All the reference variables d, a, v, o refer to the same Deer object in the heap.

    Answered on February 3, 2019.
    Add Comment

    Polymorphism in Java has two types: Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding). Method overloading is an example of static polymorphism, while method overriding is an example of dynamic polymorphism.

    An important example of polymorphism is how a parent class refers to a child class object. In fact, any object that satisfies more than one IS-A relationship is polymorphic in nature.

    For instance, let’s consider a class Animal and let Cat be a subclass of Animal. So, any cat IS animal. Here, Cat satisfies the IS-A relationship for its own type as well as its super class Animal.

    Answered on February 4, 2019.
    Add Comment

    n programming languages and type theory, polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types

    Answered on February 6, 2019.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.