Consider the following program:
public class Main { public static void main(String []args) { try {/*from ww w . j a v a2 s. c o m*/ assert false; } catch(RuntimeException re) { System.out.println("RuntimeException"); } catch(Exception e) { System.out.println("Exception"); } catch(Error e) { // LINE A System.out.println("Error" + e); } catch(Throwable t) { System.out.println("Throwable"); } } }
This program is invoked from the command line as follows:
java Main
Choose one of the following options describes the behavior of this program:
F.
By default, assertions are disabled.
if -ea or the -enableassertions
option to enable assertions, then the program would have printed "Error" since the exception thrown in the case of assertion failure is java.lang.AssertionError, which is derived from the Error class.