class B{
public void p(double i){
System.out.println("B");
}
}
class A extends B{
public void p(double i){
System.out.println("A");
}
}
class Demo{
public static void main(String args[]){
//way of using polymorphic 1
A a=new A();
a.p(10.0);
//way of using polymorphic 2
A a=new B();
a.p(10.0)
}
}
Both 2 ways provide same answer.But I want to know what is the difference between these 2 ways of using dynamic polymorphic.what is the best way to use in a program?