I need to understand something
class Father {
int var1=10;
void amethod() {
System.out.println("father method ");
}
}
class Son extends Father {
int var1=20;
void amethod() {
System.out.println("father is over ridden ");
}
void bmethod() {
System.out.println("son's method ");
}
public static void main(
String as[]) {
Father f=new Son();
System.out.println(f.var1);
//f.bmethod();
f.amethod();
}
}
I got the errorwhen I call f.bmethod(); why is that if f.amethod() access the Son class amethod() then why I can not access bmethod() by the same way???
I appreciate help
Thanx
Jaffery