Given:
3. class Shape { void print() { assert true; } } 4. public class Main extends Shape { 5. public static void main(String[] args) { 6. new Main().go(args); 7. } //www. j ava 2 s . co m 8. void go(String[] args) { 9. if(args.length > 0) print(); 10. if(args[0].equals("x")) System.out.print("x "); 11. if(args[0] == "x") System.out.println("x2 "); 12. } }
And (if the code compiles), the invocation:
java -ea Boombox2 x
What is the result?
C is correct.
A NoClassDefFoundError is thrown.
It's lame, but you have to watch out for this kind of thing.
The invocation should be java -ea Main x (both B's are capitalized).
If the invocation was correct, the answer would be A.