
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between Static binding and dynamic binding in Java
Binding is a mechanism creating link between method call and method actual implementation. As per the polymorphism concept in Java , object can have many different forms. Object forms can be resolved at compile time and run time. If linking between method call and method implementation is resolved at compile time then we call it static binding or If it is resolved at run time then it dynamic binding. Dynamic binding uses object to resolve binding but static binding use type of the class and fields.
Sr. No. | Key | Static Binding | Dynamic Binding |
---|---|---|---|
1 | Basic | It is resolved at compile time | It is resolved at run time |
2 | Resolve mechanism | static binding use type of the class and fields | Dynamic binding uses object to resolve binding |
3 | Example | Overloading is an example of static binding | Method overriding is the example of Dynamic binding |
4. | Type of Methods | private, final and static methods and variables uses static binding | Virtual methods use dynamic binding |
Example of Static and Dynamic Binding
public class FastFood { public void create() { System.out.println("Creating in FastFood class"); } } public class Pizza extends FastFood { public void create() { System.out.println("Creating in Pizza class"); } } public class Main { public static void main(String[] args) { FastFood fastFood= new FastFood(); fastFood.create(); //Dynamic binding FastFood pza= new Pizza(); pza.create(); } }
- Related Questions & Answers
- Difference Between Static and Dynamic Binding
- Static binding and dynamic binding in Java
- What are differences between static binding and dynamic binding in Java?
- Explain the difference between static and dynamic binding in Java.
- Static binding vs Dynamic binding in C#
- Static vs Dynamic Binding in Java
- Dynamic Binding in C#
- What is dynamic binding in Java?
- What is static binding in Java?
- What is dynamic binding in C#?
- Early binding and Late binding in C++
- What is static binding in C#?
- Difference between Static and Dynamic Testing
- What is binding and binding time in compiler design?
- Difference between Static and Dynamic Web Pages