Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why we not override method of HttpServlet  RSS feed

 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear sir i would like to know one thing that see as we know that in servlet HttpServlet class extends GenricServlet and as we know that both these classes are abstract and when we make any own servlet class then that should be extends HttpServlet class but as for ruls that when you extends any class that is abstract then you most override all the function of that Abstract class but here in our own servlet class we not override all the method of HttpServlet class why sir why?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arun Maalik:
but as for ruls that when you extends any class that is abstract then you most override all the function of that Abstract class


Not correct. In order for the extending class to not be abstract, it must supply implementations for any abstract methods in the base class -- not all the methods.
 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No sir see



when i am compiling above file using jdk1.5 then i am getting a compile time error that

error first is not abstract and doesn't define showData2 in first

Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read Bear's post again.

it must supply implementations for any abstract methods in the base class


The HttpServlet is abstract, its methods are not.
[ September 13, 2006: Message edited by: Ben Souther ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An abstract class can provide concrete methods. All the methods in the Servlet class we extend are concrete - it is the class itself that is abstract.

If an abstract class does not have any abstract methods, then an extending class has no obligation to override any of the inherited methods.

Isn't Java kewl?

-Cameron
 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!