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
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
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.