Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1037 :

Posted: Sun Jul 23, 2017 6:58 am
by scyber
class TestBase{
public void methodA(){
System.out.println("base - MethodA");
}
}
class Sub extends Base{
public void methodA(){
System.out.println("sub - MethodA");
}
public void methodB(){
System.out.println("sub - MethodB");
}
public static void main(String args[]){
Base b = new Sub(); //1
b.methodA();
b.methodB();
}
}
Compilation fail!!
The methodA/B can't be resolved in such example.

Any idea?

Re: About Question enthuware.ocajp.i.v8.2.1037 :

Posted: Sun Jul 23, 2017 9:20 am
by admin
Did you read the explanation? It explains exactly what you are asking.
And, please use the code exactly as given in the question. The name of the class as given in the question is Base. Not TestBase.
Paul.