class A{
void amethod(){
System.out.println("amethod");
}
void overridenmethod(){
System.out.println("in A");
}
}
class B extends A{
void bmethod(){
System.out.println("bmethod");
}
void overridenmethod(){
System.out.println("in B");
}
}
class Test{
public static void main(String args[]){
A a1 = new A();
if(a1 instanceof B){
B b1 = (B) a1;
b1.amethod();
b1.overridenmethod();
}
}
}
This code does not give any compile time or runtime error. But Output is blank. Nothing prints on console.I was expecting the below output:
amethod
in A
What am I doing wrong? Please help. Thanks in advance