Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServletConfig & ServletContext " Watch "ServletConfig & ServletContext " New topic

ServletConfig & ServletContext

Deep Gagan

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


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
B. ctx.getInitParameter("bestwebsite") will return
C. ctx.getInitParameter("bestwebsite") will return
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
Frits Walraven
Creator of Enthuware JWS+ V6

Joined: Apr 07, 2010
Posts: 1934

Hi Deep,

That is correct.

Ankit Garg

Joined: Aug 03, 2008
Posts: 9327

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:
subject: ServletConfig & ServletContext