I have given this question :
public class A {
private void a() {
System.out.println("a");
}
public static void main(String[] args) {
A t = new B();
t.a();
}
}
class B extends A {
public void a() {
System.out.println("b");
}
}
This prints output: a
I am not very sure of the answer. I know that if you create an child object and pass it to parent reference. It runs functions overridden via A only. But here the function is private, how does this work ???
I know this is not overriding. But how come output is printing "a" ?