Please find the code snippet below which explains the question.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
I ref = new B();
ref.equals("");
}
}
interface I{
}
class A {
public void method(){
}
}
class B extends A implements I{
}
Please refer to main()
, ref.equals()
is allowed but ref.method()
is not allowed. Why is so?
EDIT: Object is the super class of B (or of A or of any other class) but in the same way A is also a super class of B. My question is why A's 'method()' is not visible in 'ref', i.e. why ref.equals() is allowed but ref.method() isn't? How this method visibility check is done? Is it rooted the JVM?