Polymorphism in java

Veröffentlicht am: 22 April 2020
auf dem Kanal: ShreeHub
61
6

The word “poly” means many and “morph” means forms.It means having many forms. It is the most important concept of object-oriented programming language.Java Polymorphism allows us to perform a single task in different ways. It is used when we have multiple classes that are related to each other by inheritance.
There are two types of polymorphism in Java and they are as follows:1.Static Polymorphism in Java 2. Dynamic Polymorphism in Java

Static Polymorphism a method's behavior is bound to the definition at the time of method compilation by the compiler. This type of binding is known as static binding, and it cannot be rebound. Example: method overloading. In Java, static polymorphism is achieved through method overloading. Method overloading means there are several methods present in a class having the same name but different types/order/number of parameters.At compile time, Java knows which method to invoke by checking the method signatures.

Run-time Polymorphism: Here, the method declaration is bound to the definition by the JVM during ,run time based on the object created.
This type of binding is known as dynamic binding and it can be rebound.

In Java, run-time polymorphism can be achieved through method overriding.
Suppose the same method is created in the superclass and its subclasses.
In this case, the method that will be called depends upon the object used to call the method.


Auf dieser Seite können Sie das Online-Video Polymorphism in java mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer ShreeHub 22 April 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 61 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!