My Java Quiz

The ultimate place to learn Java!

Question #22: Which of the following is true?

public class Base {
  public String toString() {
    return "Base";
  }
}

public class Derived extends Base {
  public String toString() {
    return "Derived";
  }
}

public class Main {
  public static void main(String[] args) {
    Base b = new Derived();
    System.out.println(b);
  }
}