My Java Quiz

The ultimate place to learn Java!

Question #23: Which of the following is true?

public class A {
  public String foo() {
    return "a";
  }
}

public class B extends A {
  public String foo() {
    return "b";
  }
}

public class Main {
  public static void main(String[] args) {
    A a = (A) new B();
    System.out.println(a.foo());
  }
}