Skip to content

Instantly share code, notes, and snippets.

@NeQuissimus
Forked from tonymorris/EggsToast.java
Created August 30, 2016 13:03
Show Gist options
  • Save NeQuissimus/54092c1344fabbaa3305745048d0a4f9 to your computer and use it in GitHub Desktop.
Save NeQuissimus/54092c1344fabbaa3305745048d0a4f9 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