• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

why we not override method of HttpServlet

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic