You are on page 1of 7

10/10/23, 8:29 PM Difference between Early and Late Binding in Java - GeeksforGeeks

Java Arrays Java Strings Java OOPs Java Collection Java 8 Tutorial Java Multithreading Java Exception

Difference between Early and Late Binding in


Java
Read Discuss Practice

Early Binding: The binding which can be resolved at compile time by the
compiler is known as static or early binding. Binding of all the static, private
and final methods is done at compile-time. Example:

Java

public class NewClass {


public static class superclass {
static void print()
{
System.out.println("print in superclass.");
}
}
public static class subclass extends superclass {
static void print()
{
System.out.println("print in subclass.");
}
}

public static void main(String[] args)


{
superclass A = new superclass();
superclass B = new subclass();
A.print();
B.print();
}
}

Output:
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge
that you have read and understood our Cookie Policy & Privacy Policy
print in superclass.
Got It !
print in superclass.

https://www.geeksforgeeks.org/difference-between-early-and-late-binding-in-java/ 1/7
10/10/23, 8:29 PM Difference between Early and Late Binding in Java - GeeksforGeeks

Late binding: In the late binding or dynamic binding, the compiler doesn’t
decide the method to be called. Overriding is a perfect example of dynamic
binding. In overriding both parent and child classes have the same method.
Example:

Java

public class NewClass {


public static class superclass {
void print()
{
System.out.println("print in superclass.");
}
}

public static class subclass extends superclass {


@Override
void print()
{
System.out.println("print in subclass.");
}
}

public static void main(String[] args)


{
superclass A = new superclass();
superclass B = new subclass();
A.print();
B.print();
}
}

Output:

Check out our 'Data Structures and Algorithms - Self Paced' course and boost
your knowledge 🚀

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge
that you have read and understood our Cookie Policy & Privacy Policy

https://www.geeksforgeeks.org/difference-between-early-and-late-binding-in-java/ 2/7
10/10/23, 8:29 PM Difference between Early and Late Binding in Java - GeeksforGeeks

print in superclass.
print in subclass.

Difference table between early and late binding:

Early Binding Late Binding

It is a compile-time process It is a run-time process

The method definition and method call The method definition and method
are linked during the compile time. call are linked during the run time.

Actual object is not used for binding. Actual object is used for binding.

For example: Method overloading For example: Method overriding

Program execution is faster Program execution is slower

Last Updated : 21 Feb, 2023 7

Similar Reads
Difference between Early Difference between
and Delayed Token Release Compile Time and Load
Time address Binding

Difference between Load Difference between


Time and Execution Time Compile Time and
address binding Execution Time address…

Differences between Static vs Dynamic Binding


Dynamic Binding and in Java
Message Passing in Java

Java Architecture for XML Overview of Data Binding in


Binding ( JAXB ) | Set-1 Android Architecture
Components
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge
How to Implement View
that you have read and understood our Cookie Policy & Privacy PolicyData Binding in Android
Binding Inside Dialog in with Example
Android?

Related Tutorials
https://www.geeksforgeeks.org/difference-between-early-and-late-binding-in-java/ 3/7
10/10/23, 8:29 PM Difference between Early and Late Binding in Java - GeeksforGeeks

Java AWT Tutorial Spring MVC Tutorial

Spring Tutorial Spring Boot Tutorial

Java 8 Features - Complete


Tutorial

Previous Next

CharMatcher fields with Examples | ByteBuffer getDouble() method in Java


Guava | Java with Examples

Article Contributed By :
chaitanyashah707
C chaitanyashah707

Follow

Vote for difficulty


Current difficulty : Medium

Easy Normal Medium Hard Expert

Improved By : vivekkumar01
Article Tags : Picked , Difference Between , Java
Practice Tags : Java

Improve Article Report Issue

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge
that you have read and understood our Cookie Policy & Privacy Policy

https://www.geeksforgeeks.org/difference-between-early-and-late-binding-in-java/ 4/7
10/10/23, 8:29 PM Difference between Early and Late Binding in Java - GeeksforGeeks

DSA to Development: A Complete


Guide
Are you ready to transition from a DSA enthusiast to a
versatile developer? Explore our comprehensive course,
"DSA to Development: Coding Guide."
Gain Mastery Acquire Insights

Mentorship by Experts LEARN MORE

A-143, 9th Floor, Sovereign Corporate


Tower, Sector-136, Noida, Uttar Pradesh -
201305
feedback@geeksforgeeks.org

Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Careers GfG Weekly Contest
In Media Offline Classes (Delhi/NCR)
Contact Us DSA in JAVA/C++
Advertise with us Master System Design
Campus Training Program Master CP

Languages DSA Concepts


Python Data Structures
Javathe best browsing experience on our website. By using our site,Arrays
We use cookies to ensure you have you acknowledge

C++
that you have read and understood our Cookie Policy & Privacy Policy
Strings
PHP Linked List
GoLang Algorithms
SQL Searching

https://www.geeksforgeeks.org/difference-between-early-and-late-binding-in-java/ 5/7
10/10/23, 8:29 PM Difference between Early and Late Binding in Java - GeeksforGeeks

R Language Sorting
Android Tutorial Mathematical
Dynamic Programming

DSA Roadmaps Web Development


DSA for Beginners HTML
Basic DSA Coding Problems CSS
DSA Roadmap by Sandeep Jain JavaScript
DSA with JavaScript Bootstrap
Top 100 DSA Interview Problems ReactJS
All Cheat Sheets AngularJS
NodeJS
Express.js
Lodash

Computer Science Python


GATE CS Notes Python Programming Examples
Operating Systems Django Tutorial
Computer Network Python Projects
Database Management System Python Tkinter
Software Engineering OpenCV Python Tutorial
Digital Logic Design Python Interview Question
Engineering Maths

Data Science & ML DevOps


Data Science With Python Git
Data Science For Beginner AWS
Machine Learning Tutorial Docker
Maths For Machine Learning Kubernetes
Pandas Tutorial Azure
NumPy Tutorial GCP
NLP Tutorial
Deepyou
We use cookies to ensure Learning Tutorial
have the best browsing experience on our website. By using our site, you acknowledge
that you have read and understood our Cookie Policy & Privacy Policy

Competitive Programming System Design


Top DSA for CP What is System Design
Top 50 Tree Problems Monolithic and Distributed SD

https://www.geeksforgeeks.org/difference-between-early-and-late-binding-in-java/ 6/7
10/10/23, 8:29 PM Difference between Early and Late Binding in Java - GeeksforGeeks

Top 50 Graph Problems Scalability in SD


Top 50 Array Problems Databases in SD
Top 50 String Problems High Level Design or HLD
Top 50 DP Problems Low Level Design or LLD
Top 15 Websites for CP Top SD Interview Questions

Interview Corner GfG School


Company Wise Preparation CBSE Notes for Class 8
Preparation for SDE CBSE Notes for Class 9
Experienced Interviews CBSE Notes for Class 10
Internship Interviews CBSE Notes for Class 11
Competitive Programming CBSE Notes for Class 12
Aptitude Preparation English Grammar

Commerce UPSC
Accountancy Polity Notes
Business Studies Geography Notes
Economics History Notes
Human Resource Management (HRM) Science and Technology Notes
Management Economics Notes
Income Tax Important Topics in Ethics
Finance UPSC Previous Year Papers
Statistics for Economics

SSC/ BANKING Write & Earn


SSC CGL Syllabus Write an Article
SBI PO Syllabus Improve an Article
SBI Clerk Syllabus Pick Topics to Write
IBPS PO Syllabus Write Interview Experience
IBPS Clerk Syllabus Internships
Aptitude Questions
SSC CGL Practice Papers
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge
that you have read and understood our Cookie Policy & Privacy Policy
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

https://www.geeksforgeeks.org/difference-between-early-and-late-binding-in-java/ 7/7

You might also like