DEV Community

Arun Kumar
Arun Kumar

Posted on

Compile-Time and Runtime Polymorphism in Java

  • Compile-Time Polymorphism in Java

Compile Time Polymorphism In Java is also known as Static Polymorphism. Furthermore, the call to the method is resolved at compile-time. Compile-Time polymorphism is achieved through Method Overloading.

  • Runtime Polymorphism in Java Method Overriding is done when a child or a subclass has a method with the same name, parameters, and return type as the parent or the superclass; then that function overrides the function in the superclass. In simpler terms, if the subclass provides its definition to a method already present in the superclass; then that function in the base class is said to be overridden.

Reference:

https://www.mygreatlearning.com/blog/polymorphism-in-java/

[Operator overloading - to be discussed]

Syntax of early binding

ClassName objectName = new ClassName ();

syntax for late binding

Class name objectName = new DerivedClassName();

Top comments (0)