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 marcus green: Mock test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "marcus green: Mock test" Watch "marcus green: Mock test" New topic
Author

marcus green: Mock test

Marut pandey
Ranch Hand

Joined: Mar 10, 2008
Posts: 43
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

Answer is C only . I guess E option is also correct.

Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

Hi, the best you can do, is test that on a webapp of example.

I think you all right, because the interface ServletContext, dont have the method, getServletConfig(), and getting a servlet config from a ServletContext, dont have any sence.
ani jadhao
Ranch Hand

Joined: Dec 23, 2008
Posts: 62
Best option I would suggest you to try by yourself on any intelligent java/j2ee editor. Try oberving methods of servletcontext. And also think , would it make sense to have a getservletconfig method in servlet context.?

the given answer in question is correct.


SCJP 1.4 : 91%
SCWCD 5: 96%
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Milton is right: ServletContext has no such method. E is the only answer that wouldn't even compile.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: marcus green: Mock test
 
Similar Threads
ServletConfig & ServletContext
ServletContext related
answers to questions in Macus Green tests
Doubt on servlets
Which statement is true regarding initialization parameter