ok..Now my aim is to tell you about very important OPP concept.
That is dynamic binding..
It uses the names runtime binding/late binding and so on.
Dynamic Binding....
** The actual owner of the object will be checked while the runtime..
See the below example..
class Vehical {
public void getName(){
System.out.println("This is a vehical");
}
}
class Car extends Vehical{
public void getName(){
System.out.println("This is a Hybrid");
}
public static void main(String args[]){
Vehical V=new Car();
V.getName();
}
}
The output is......."This is a Hybrid".
That is dynamic binding..
It uses the names runtime binding/late binding and so on.
Dynamic Binding....
** The actual owner of the object will be checked while the runtime..
See the below example..
class Vehical {
public void getName(){
System.out.println("This is a vehical");
}
}
class Car extends Vehical{
public void getName(){
System.out.println("This is a Hybrid");
}
public static void main(String args[]){
Vehical V=new Car();
V.getName();
}
}
The output is......."This is a Hybrid".