Pls check this code:
==========================================
class Base{
void methodA(){
System.out.println("methodA");
}
}
class Sub extends Base{
void methodB(){
System.out.println("methodB");
}
public static void main(
String a[]){
Base oBase = new Sub();
oBase.methodB(); //causing the error
}
}
===========================================
Here, even I have created base object, assigning the reference of Sub. Now why I am not able to call a methodB() which is exisitn in Sub class???
When I put the methodB() in Base class its workign fine.