This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
This is question 6 from RHE I/O Test (Chapter 13, page 471)
What does the following code fragment print out at line 9?
The answers given are (Choose only one type radio buttons)- A) The output is i = 30. B) The output is i = 20. C) The output is i = 10. D) There is no output because the code throws an exception at line 1. E) There is no output because the code throws an exception at line 5.
But the code is not included in the try-catch blocks, so it will not compile, Do we have to assume that the code is included in the try-catch block? I ask this because in the previous qusetion of the same test, the code is enclosed in the try-catch block. Do I have to make a similar assumptio in the actual exam, since "Code will not compile" option is not there in the answers? I have looked it in the RHE errata, but there's no explanation available for this one. Also, the semi-colon is missing on line 8, but I think it's only a typo and in the actual exam, I hope that we will not be tested for its presence for compilaltion, all other things being correct.
HI Manish, The important thing is to read the question VERY carefully. This is extremely important during the exam. In this case, the question says: code fragement no compilable, complete program. Since we are dealing with a code segment we need to assume that code not shown is present and is not important to finding the answer. The exam will use similar questions but I think will say something like: assuming the code will compile in the context in which it will be used ... Also, the text is multiple choice. Therefore, get used to looking at the answers in developing your thoughts. If the semi-colon was not a typo wouldn't one of the answers be won't compile? If the try catch issue was an issue wouldn't one of the answers be won't compile? The exam is meant for people to think through problems because that is what real-life programming is all about. The answers might not be obvious at first glance, but a little investigation will reveal the results. NOTE: The exam won't have ANY typos because the questions have been investigated to the fullest to be clear precise. Regards, Manfred.