If I have two classes, A and B,
public class A { public int test() { return 1; } } public class B extends A{ public int test() { return 2; } }
If I do: A a1 = new B() , then a1.test() returns 2 instead of 1 as desired. Is this just a quirk of Java, or are there some reasons for this behavior?
user577304
source share