• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

nice q from jiris mock exam

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which statements are TRUE regarding the following code? Mark

Please select two correct answers.



import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends GenericServlet {

public void init() { //1
// Do something
}

public void init(ServletConfig config) //2
throws ServletException{
// Do something
super.init(config); //3
}

public void destroy() { //4
// Do something
}

public void service(ServletRequest req, //5
ServletResponse res) {
// Do something
}
}

A : Method //1 is necessary for this code to compile
B : Method //2 is necessary for this code to compile
C : Line //3 is necessary for this code to run
D : Method //4 is necessary for this code to compile
E : Method //5 is necessary for this code to compile

ANSWER: C, E
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As the GenericServlet have a abstract service() method, It should be override by the extending Servlet.

The option C is correct. The Code will compile without this method call, but the ServletConfig object will not available. The Specification mandate when overriding this form of method, call super.init(config). Looking reasonable.

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic