Page 1 of 1

About Question enthuware.ocajp.i.v7.2.846 :

Posted: Wed Mar 21, 2012 10:53 pm
by ETS User
Look at this question:
public class TestClass {

public static void doStuff() throws Exception{
System.out.println("Doing stuff...");
if(Math.random()>0.4){
throw new Exception("Too high!");
}
System.out.println("Done stuff.");
}

public static void main(String[] args) throws Exception {
doStuff();
System.out.println("Over");
}
}

The program says that the correct answers are:
Doing stuff...
Exception in thread "main" java.lang.Exception: Too high!
at TestClass.doStuff(TestClass.java:29)
at TestClass.main(TestClass.java:41) Agreed

AND

Doing stuff...
Done stuff. Not agreed

My point is: if the program reaches the "Done stuff", isn't it obligated to run the "Over"?

Re: About Question enthuware.ocajp.i.v7.2.846 :

Posted: Thu Mar 22, 2012 6:18 am
by admin
Yes, and Over is indeed a part of correct option 3.

HTH,
Paul,