0 votes
in JAVA by
What is the difference between compile-time polymorphism and runtime polymorphism?

1 Answer

0 votes
by

There are the following differences between compile-time polymorphism and runtime polymorphism.

SNcompile-time polymorphismRuntime polymorphism
1In compile-time polymorphism, call to a method is resolved at compile-time.In runtime polymorphism, call to an overridden method is resolved at runtime.
2It is also known as static binding, early binding, or overloading.It is also known as dynamic binding, late binding, overriding, or dynamic method dispatch.
3Overloading is a way to achieve compile-time polymorphism in which, we can define multiple methods or constructors with different signatures.Overriding is a way to achieve runtime polymorphism in which, we can redefine some particular method or variable in the derived class. By using overriding, we can give some specific implementation to the base class properties in the derived class.
4It provides fast execution because the type of an object is determined at compile-time.It provides slower execution as compare to compile-time because the type of an object is determined at run-time.
5Compile-time polymorphism provides less flexibility because all the things are resolved at compile-time.Run-time polymorphism provides more flexibility because all the things are resolved at runtime.

Related questions

+1 vote
asked Jan 24, 2020 in JAVA by rahuljain1
+1 vote
asked May 24, 2019 in JAVA by rajeshsharma
...