creating instances of classes in context of parent child relation ship-java
i am trying to understand how instances of class or subclass are created in parent/child context.Take a look at this code:

    class A  {
    public void methodl() { //class "A" method caled } 
}  
class B extends A  {  
public void methodl() { //class "B" method caled } 
}  
public class Test  {  public static void main(String args[])  {  
//case 1  
A a=new A();  
a.method1();  
//case 2  
B b=new B();  
b.method1();  
//case 3  
A a=new B();  
a.method1();  
//case 4  
B b=new A();  
b.method1();  
} 
}

Any suggestion

 
creating instances of classes in context of parent child relation ship-java
===

i am trying to understand how instances of class or subclass are created in parent/child context.Take a look at this code:

    class A  {
    public void methodl() { //class "A" method caled } 
}  
class B extends A  {  
public void methodl() { //class "B" method caled } 
}  
public class Test  {  public static void main(String args[])  {  
//case 1  
A a=new A();  
a.method1();  
//case 2  
B b=new B();  
b.method1();  
//case 3  
A a=new B();  
a.method1();  
//case 4  
B b=new A();  
b.method1();  
} 
}

Any suggestion

 