Instantly share code, notes, and snippets.

@benjholla /Puzzle18.java Secret
Created Oct 19, 2018

Embed
What would you like to do?
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