This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServletConfig & ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServletConfig & ServletContext " Watch "ServletConfig & ServletContext " New topic
Author

ServletConfig & ServletContext

Deep Gagan
Greenhorn

Joined: Aug 03, 2007
Posts: 11
Given a valid deployment descriptor (WEB.XML) containing the following code

<context-param>
<param-name>bestwebsite</param-name>
<param-value>www.examulator.com</param-value>
</context-param>
<servlet>
<servlet-name>GetInitParameter</servlet-name>
<servlet-class>com.examulator.GetInitParameter</servlet-class>
<init-param>
<param-name>bestwebsite</param-name>
<param-value>www.javaranch.com</param-value>
</init-param>
</servlet>

And given that cfg is a valid ServletConfig object and ctx is a valid ServletContext object which of the following statements are true?


Choose at least one answer.
A. cfg.getInitParameter("bestwebsite") will return www.examulator.com
B. ctx.getInitParameter("bestwebsite") will return www.javaranch.com
C. ctx.getInitParameter("bestwebsite") will return www.examulator.com
D. cfg.getServletContext().getInitParameter("bestwebsite"); will cause a compile time error
E. ctx.getServletConfig().getInitParameter("bestwebsite"); will cause a compile time error

I think answer is C & E. Is it correct?

Thanks & Regards
SCJP, SCWCD
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2007
    
  39

Hi Deep,

That is correct.

Regards,
Frits
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9400
    
  20

Deep please QuoteYourSources when you post a mock exam question...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletConfig & ServletContext
 
It's not a secret anymore!