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 ]
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.
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>
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.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com