Introduction
This article will explain one of the concepts of Java, Binding, along with some simple examples related to the concept to make a clear understanding.
If you have more than one method of the same name or two variables of the same name then there will be confusion during the compile-time and runtime of which method or variable is to be used as the reference code. This problem can be handled by the binding concept. Actually a connection made between the method call and the method body is known as binding.
Concept of Binding in Java
Types of Binding
- Static binding (early binding)
- Dynamic binding (late binding)

Before proceeding further let's explain some basic definitions.
We need to understand the type of instances that are used in Java and they are variable, references, and object.
int A=30; float B=2.4; char C="Rahul";
Here the three variables A, B, C are of different types.
Here phone is a type of electronics. Phone is a reference of electronics.
Here nokia is an instance of the phone class, but it is also an instance of the electronics class.
When the binding can be resolved or the object can be determined at compile time by the compiler, then it is known as static binding. It is also called early binding.
All final, static, and private methods and variables are resolved by the static binding.
All overloaded methods are resolved by the static binding. Static binding uses type (class in Java) information to resolve binding.
A simple example of static binding is as in the following:
Variable type
Reference type
- class Electronics {
- public static void main(String args[]) {
- Electronics phone=new Electronics(); } }
Object type
- class Building {
- void structure() {
- System.out.println("10 floors");
- }
- }
- class Room extends Building {
- void structure() {
- System.out.println("B H K flat");
- }
- public static void main(String args[]) {
- Building b = new Room();
- b.structure();
- }
- }

Gowtham RajamanickamPosted May 19, 2015, 12:50 AM
good one