Contact Us || Privacy Policy || About Us |
|
Polymorphism in JavaPolymorphism is most important features of OOPs concept. Polymorphism is derived from two Greek words poly and morphs.where the word "poly" means many and "morphs" means forms. which Polymorphism can take a single action in different ways. that is called Polymorphism. Types of Polymorphism
1) Compile Time PolymorphismCompile time polymorphism is also known as static polymorphism is a process in which a call to an overloading method is resolved at compile time rather than at run time. Example: Output ![]() 2) Run Time PolymorphismRuntime polymorphism is also known as Dynamic Method Dispatch which call to an overridden method is resolved at runtime . Upcasting in javaRuntime polymorphism is provide a upcasting If the reference variable of Parent class refers to the object of Child class, it is known as upcasting In other words, subclass to a superclass is called upcasting. ![]() Syntax: Example(upcasting): Output:-: ![]() Runtime Polymorphism Example in JavaExample: Output:-: ![]() |