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?
About Question enthuware.ocajp.i.v8.2.1037 :
Moderator: admin
-
- Posts: 3
- Joined: Sat Jul 08, 2017 4:42 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1037 :
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.
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.
Who is online
Users browsing this forum: No registered users and 24 guests