Core Java SQL Oracle PHP Examples JSP JDBC MORE

Java dynamic binding


Binding

Linking of a procedure call to the code to be executed.

Binding is devided into 2 types:

  1. static binding
  2. dynamic binding

static binding

The binding is done at static time/compilation time is known as static binding.

Example of static binding

class student{
private void play(){System.out.println("student is playing...");}
public static void main(String args[]){
Student s1=new Student();
s1.play();
} }

output:student is playing...

Dynamic binding

The binding is done at runtime is called as dynamic binding.

Example

class Student{
void play(){System.out.println("Student is playing...");}
}
class Talent student extends Student{
void play(){System.out.println("Talent student is playing...");}
public static void main(String args[]){
Student p=new Talent student();
p.play();
}
}

output:Talent student is playing...