Given:
class Printable { void print() { assert false; }/*from w w w. j a v a2 s . c o m*/ } public class Main extends Printable { public static void main(String[] args) { new Main().go(args); } void go(String[] args) { if (args.length > 0) print(); if (!args[0].equals("x")) System.out.println("!x"); } }
And, if the code compiles, the invocation:
java -ea Main
What is the result?
F is correct.
The java invocation passes no arguments to main()
, so the args array has a length of 0, print()
is not called, and line 10 throws an exception.