Skip to content

Instantly share code, notes, and snippets.

@benjholla
Created October 19, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjholla/b3f234b30ad2eb7b75ad3a8662435c8a to your computer and use it in GitHub Desktop.
Save benjholla/b3f234b30ad2eb7b75ad3a8662435c8a to your computer and use it in GitHub Desktop.
Java Puzzle 18
public class Puzzle18 {
public static void main(String[] args){
A answer = new B();
System.out.println("Is the second exam comprehensive?");
answer.print();
}
public static class A extends Object {
public void print() {
System.out.println("Yes.");
}
}
public static class B extends A {
public void print() {
System.out.println("Yes kind of, but that wasn't the goal.");
}
}
public static class C extends B {
public void print() {
System.out.println("No, but you should understand everything...");
}
}
public static class D extends Object {
public void print() {
System.out.println("I'm not sure, I haven't made it yet...");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment