Multiple Choice Question

Quiz Guidelines

 

QID: 
254
Question: 

What will the following program print when run using the command line: java TestClass

public class TestClass {
public static void methodX() throws Exception {
throw new AssertionError();
}
public static void main(String[] args) {
try{
methodX();
}
catch(Exception e) {
System.out.println("EXCEPTION");
}
}
}

Select 1 option

A. It will throw AssertionError out of the main method.
B. It will print EXCEPTION.
C. It will not compile because of the throws clause in methodX().
D. It will end without printing anything because assertions are disabled by default.

Q&A Set: