I am having this doubt from so long so finally asking here. Let me give you an example.
class A{
void run(){
System.out.println("hi");
}
}
class B extends A{
void jump(){
}
}
public class test{
public static void main(String[] args){
A a = new A(); //statement 1
A a1= new B(); //statement 2
B b= (B) new A(); // statement 3
a.run();
b.run();
b.jump();
}};
Now my basic doubt is what is the difference between statement1,2,3? please someone explain me.