• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question related to Abstract class HttpServlet

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I know that HttpServlet is an abstract class. Meaning one or other methods would not be having any implementation. In a servlet program when we extend HttpServlet, it is obvious that we do not implement all the methods. Then how does servlet container initiates the servlet, when the servlet does not provide implementation to all the abstract methods (if any). Does anyone provides a default implementation to the remaining methods before the servlet object is instantiated.

Thanks
Ravi C. Kota
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class is abstract, but none of the methods are. That means you need to extend the class to get an executable class that can be instantiated, but you don't neeed to override any of the methods.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

don't we can call a class as abstract only when atleast one method is not implemented? or is that a class can be declared as abstract even though all the methods have implementation. Please clarify on this. If my first point is correct, then HttpServlet is abstract only if atleast one of its methods does not have any method. Now when we extend that class don't we need to provide implementation for that method. I think I'm bit confused here. Please clarify on my query.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chandra Kota:
or is that a class can be declared as abstract even though all the methods have implementation.
Yes.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
don't we can call a class as abstract only when atleast one method is not implemented?


This is a common misconception but nothing in the language specification requires it.

In this case the designers make the class abstract to force you to create your own implementation. Providing minimum implementation of all the required methods means you only have to worry about methods specific to your problem.

Bill
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!