• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

marcus green: Mock test

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Milton is right: ServletContext has no such method. E is the only answer that wouldn't even compile.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic