• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

doubt in Exam Kit Book

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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 ?
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Dee Brown
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
reply
    Bookmark Topic Watch Topic
  • New Topic