GeeCON Prague 2014*
The moose likes Mock Exam Errata and the fly likes Loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Loop" Watch "Loop" New topic
Author

Loop

zarina mohammad
Ranch Hand

Joined: Jun 26, 2002
Posts: 104
the following example is from Dan's mock exam.

the output on my system was 3 ,6 ,8 ,10 ,13 ,15 ,17,20.
but actually given as 3,5,9,11,14,16,19
why is the o/p varying in my system?
can someone try this code. And tell me the result.
thanks
zarina
[ January 12, 2003: Message edited by: Marilyn de Queiroz ]
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I ran the code and the ouput was the same as yours, namely 3, 6, 8, 10, 13, 15, 17, 20,
If you try to "execute" the code in your head, you'll see that the given answer cannot be correct.
First, i and j are 0. Then, i gets incremented twice (i=2) and j once (j=1). A first output i+j (3) is printed. The switch resolves to default and the execution continues at label1. i gets incremented twice again (i=4) and j once (j=2). The second output can only be 6 (i+j=6) and nothing else. From there on, it's clear that the given answer is wrong.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
You are both correct. I apologize for the error.
The case statement for the value 3 was missing so the code did not produce the output that matches the answer. The easiest way for me to fix the bug was to add the missing case statement. Changing the answer would have been more difficult because that would require me to come up with a variety of new answer options that would be correct only if a person made a common mistake.
I added the fix to both the July 4 and July 8 versions of the exam on the web site and also to the xml source document.
Thank you.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

moving this to Mock Exam Errata --- even though Dan has addressed the issue.
Amir Ghahrai
Ranch Hand

Joined: Jun 19, 2002
Posts: 110
To me, that looks like a blinking loop


Amir
kishor rao
Ranch Hand

Joined: Dec 10, 2002
Posts: 35
same o/p here fellas, though the didnt copy and i had to fill in . <- did that appear as a smiley too?
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
Thanks, Dan
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
That question was from a very old version of the exam and it is no longer available on my web site. I removed the questions with triple nested loops. Also, I removed questions with unnecessarily complex switch statements.
Just as the question has been removed from the mock exam, this thread should be removed from this message board.
 
Don't get me started about those stupid light bulbs.
 
subject: Loop