File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doubt  in Exam Kit Book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubt  in Exam Kit Book" Watch "doubt  in Exam Kit Book" New topic
Author

doubt in Exam Kit Book

gopal venu
Ranch Hand

Joined: Jan 06, 2006
Posts: 55


Assuming that getNameFromDBSomeHow() returns null, which of the following
statements regarding this code are correct? (Select one)
a It will throw an InvalidStateException while serving a request.
b It will throw a ServletException while serving a request.
c It will throw a NullPointerException while serving a request.
d It will throw an IllegalStateException while serving a request.
e It will not throw an exception.

Anwer given is : D.
But as per the spec after SendRedirect() any out will be ignored as its content is in buffer.No exception will occur.
My Answer is: E and i run this exam on my server and my answer is right.

Now biggest question is what to do with similar kind of questions in exam ?
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
1) I believe you are correct because the result of the final println is ignored.

2) Verify your errata using the appropriate spec, and use the answer provided by the spec since that is what the exam is based on.
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
You're right. Since the output stream is not committed, there is no way an ISE will ever be thrown.

An ISE is thrown when the stream is committed before calling sendError(). E.g.:


Note that neither the errorpage, nor the exception reaches the client. The browser will show "hello", and the ISE is written in a log file on the server.

If you do this:

the error page shows up and no ISE is thrown at all.


Surprisingly, if one does this:

an error page shows up with an ISE (code 500)!!! One should expect that
- the 405-error page is sent to the client
- an ISE is thrown on the second sendError()
- a 500-error page doesn't reach the client, just like in my first code snippet.

Does anyone have a logical explanation for this?


Originally posted by gopal venu:
[CODE]
...
Now biggest question is what to do with similar kind of questions in exam ?


The real exam doesn't show you the answers, so you won't have that problem
[ June 18, 2008: Message edited by: Jan Sterk ]

SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
"Verify your errata using the appropriate spec, and use the answer provided by the spec since that is what the exam is based on."

This was a reference on how to deal with the incorrect answers in books and mock exams. Because it has received a little more scrutiny, you are less likely to encounter such questions on the real (Sun sponsored) exam.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt in Exam Kit Book