Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Difference Between Compile-time and Run-time Polymorphism in Java

Compile-time Vs. Run-time Polymorphism: What is the difference between Compile-time Vs. Run-time Polymorphism in Java?

Polymorphism is one of the most important concepts in Java by which we can make a single action in different ways. When it comes to the types of polymorphism, there are two types: Compile time polymorphism (Static) or (Dynamic) Runtime polymorphism. Let’s analyze the difference between Compile-time and Run-time Polymorphism in Java.

What Is Compile-time Polymorphism?

Compile-time polymorphism is obtained through method overloading. The term method overloading allows us to have more than one method with the same name. Since this process is executed during compile time, that’s why it is known as Compile-Time Polymorphism.

What Is Run-time Polymorphism?

When a polymorphism receives the information to call a method and that to be in runtime, then it is called runtime polymorphism.

Difference Between Compile-time and Run-time Polymorphism in Java

Sr.No Compile Time Polymorphism Runtime Polymorphism
1. We can explain compile-time polymorphism through method overloading. Compile-time polymorphism allows us to have more than one method share the same name with different signatures and different return types. We can explain run-time polymorphism through method overriding. Run-time polymorphism is allied in different classes but allows us to have the same method with the same signature name.
2 In this, the call is determined by the compiler. In this, the call is not determined by the compiler.
3 The method is executed quite earlier at the compile-time, and that’s why it provides fast execution. The method is executed at the run-time, and that’s why it provides slow execution.
4 This polymorphism is also known as early binding, overloading, and static binding. This polymorphism is also known as late binding, dynamic binding, and overriding.
5 It is obtained by operator overloading and function overloading. It is obtained by pointers and virtual functions.
6 It is less manageable as it performs at compile time. It is more flexible as it executes at run time.

Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2023, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cut off, GATE Previous Year Question Paper, and more.

Also Explore,

 

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*