Hello.
I got a simple question, that I thought would work, but it didn�t. I have 3 classes. Let�s say A, B and C. On class A I got the main. C extends B. I got a method on class B that I want to access in the main method at class A. Let�s see the example:
public class A {
public static void main(
String[] args) {
B instance = new C();
// or C instance = new C();
instance.hello();
}
}
public class B {
String hello(){
return ("hello");
}
}
public class C extends B {}
I was really sure this would work, but didn�t. Since C extends B, once instantiated, it shoud access it�s methods, because it�s not private. But the code above gives no compilation error, neither shows any output. What�s wrong?
Thanks.