This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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
Explanation
You need to override the service() method when you extends GenericServlet. You need to call super.init(config) if you override this method
I dont remember the answer given but i guess its C and E from the explanation given. Wanted to know if the explanation given is right.!Can we overide the Service menthod is we extend Generic Servlet??
Thanks and Regards,<br />Nilesh<br />SCJP 1.4, SCWCD 1.4
the class GenericServlet implements the interface Servlet. But the class doesnt implement all the methods, it doesnt implement the service(ServletRequest, ServletResponse) method, and thats why the GenericServlet class is declared abstract.
Since the servlet in the question extends the GenericServlet, option E is correct !
and about option C its correct because -
the code overrides the init(ServletConfig) nethod. Thus the container wont call the method (this method has a call to the init( ) method )that is inherited from the class GenericServlet. So in order that your init( ) method should be called, you must place a super.init(ServletConfig) method [ in your init(ServletConfig) ], which in turn has a call to the init( ) method that is already coded at line 1 .
hope this doesnt confuse you !
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ] Performance is a compulsion, not a option, if my existence is to be justified.