Calling a method body is known as binding. There are two types of bindings-

  • Static Binding
  • Dynamic Binding

 
1. Static Binding – It is also known as early binding. When type of an object is determined at compile time, then it is known as static binding. When there is private, static and final keyword is used in the class then there is static binding.
e.g.

class Calculation
{
public void operation()
{
System.out.println("Calculation class");
}
public static void main(String[] args)
{
Calculation c =new Calculation ();
c.operation();
}
}

Output
Calculation class
 
2. Dynamic Binding – It is also known as late binding. When type of an object is determined at run time, then it is known as static binding.
e.g.

class Flower
{
public void smell()
{
System.out.pritnln("Class Flower");
}
}
 
class Rose extends Flower
{
public void smell()
{
System.out.println("Class Rose");
}
public static void main(String[] args)
{
Flower fl=new Rose ();
fl.smell();
}
}

Output
Class Rose
Learn more about Cross-Platform Mobile Technology for Android and iOS using Java in this insightful blog now!

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
24 − 21 =