Q which method in the abstract class HttpServlet is abstract and must be overridden? A)protect void service(HttpServletRequest,HttpServletResponse) B)protect void doGet(HttpServletRequest,HttpServletResponse) C)protect void doPost(HttpServletRequest,HttpServletResponse) D)portected void init() E) none of the above
Correct answere E
But if i change this question which method(any of one) in the abstract class HttpServlet is must be overridden?
then correct answere B and C is it right? please any one confirm me..
Best Regards,<br />Vipin<br />MCA, SCJP5, SCWCD in progress
Again it's not a must. But if you have some initialization code for servlet to use (getting a DB connection may be) you will override the no-arg version of init(). You may go through the Servlet spec which has breif explanations on all these methods.
To clarify, I'll quote from the explanation of the answers given on p.63:
Correct answer: E. No methods in HttpServlet are abstract, even though the class is! However, good practise dictates that one of the doXxx() methods be overridden, even though they have default implementations.
Of course you don't have to override any doXxx(), but if you don't it makes the servlet pretty useless... Often you'll override doGet() and sometimes doPost(). As mentioned above, there are cases when you might also want to override init() too. [ December 05, 2008: Message edited by: Charles Lyons ]
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
Eat that pie! EAT IT! Now read this tiny ad. READ IT!