Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Q 14 page 61 Authore Charles lyons

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
vipin jain
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Be careful of typos when you post some code. The access identifier is "protected", not "protect", or "portected")
 
Vijitha Kumara
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Vijitha

sorry for typos problem.....
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic