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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ETS User

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

Post 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"?

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Yes, and Over is indeed a part of correct option 3.

HTH,
Paul,

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 14 guests