aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Q 14 page 61 Authore Charles lyons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Q 14 page 61 Authore Charles lyons" Watch "Q 14 page 61 Authore Charles lyons" New topic
Author

Q 14 page 61 Authore Charles lyons

vipin jain
Ranch Hand

Joined: Aug 24, 2008
Posts: 122
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
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

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?


Well, it's not a must. Of course if you want your servlet to serve GET and POST request then you should.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
vipin jain
Ranch Hand

Joined: Aug 24, 2008
Posts: 122
Thanks Vijitha
One more query.....
what about D option it should be or not please explain me region also

I looking for your positive responces.......

Thanks in advances
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

(Be careful of typos when you post some code. The access identifier is "protected", not "protect", or "portected")


[My Blog]
All roads lead to JavaRanch
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

what about D option it should be or not


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.
vipin jain
Ranch Hand

Joined: Aug 24, 2008
Posts: 122
thanks Vijitha

sorry for typos problem.....
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
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 / Amazon Amazon UK )
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q 14 page 61 Authore Charles lyons