This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock Question Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock Question Doubt" Watch "Mock Question Doubt" New topic
Author

Mock Question Doubt

deepesh soni
Greenhorn

Joined: Jul 13, 2007
Posts: 25
Which of the following statements are true?
Choose at least one answer.
A. Every (non distributed) web application has only one instance of ServletContext Correct
B. Every instance of HttpServlet has only one instance of ServletContext Incorrect
C. The ServletContext object is retrieved via the getServletContext method of ServletConfig Correct
D. The ServletConfig object is retrieved via the getServletConfig method of ServletContext Incorrect

my question is why is option 2 is wrong.(It is from examulator.com)


scjp 1.4 (90%)
scwcd 5 (88%)
Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
Hi,

Looks like a mistake to me.

Could it be the question is badly worded?
"Every instance of HttpServlet has only one instance of ServletContext" could be read as
a) Every single instance points to one and only one instance of a ServletContext object (i.e. they don't contain a map of them, just a reference to one, which would be true)
b) Every single instance points to the exact same ServletContext (which would be false for distributed applications).

Make sense?

MG


28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
Its because if the web application is in a distributed environment then each servlet will have one ServletContext per JVM


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock Question Doubt