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.
In questa pagina del sito puoi guardare il video online Polymorphism in java della durata di ore minuti seconda in buona qualità , che l'utente ha caricato ShreeHub 22 April 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 61 volte e gli è piaciuto 6 spettatori. Buona visione!