Skip to content

Instantly share code, notes, and snippets.

@tonymorris
Created August 29, 2016 12:46
Show Gist options
  • Save tonymorris/f092b78def29a2437fd1699afb88fdf5 to your computer and use it in GitHub Desktop.
Save tonymorris/f092b78def29a2437fd1699afb88fdf5 to your computer and use it in GitHub Desktop.
What is the output of this program?
// What is the output of this program?
// a) x = 2
// b) x = 3
// c) compile-error
// d) runtime exception
// e) something else _____
abstract class Eggs {
abstract void m();
Eggs() {
m();
}
}
class Toast extends Eggs {
private int x = 2;
Toast() {
x = 3;
}
public void m() {
System.out.println("x = " + x);
}
public static void main(String[] args) {
new Toast();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment