Created
August 29, 2016 12:46
-
-
Save tonymorris/f092b78def29a2437fd1699afb88fdf5 to your computer and use it in GitHub Desktop.
What is the output of this program?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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