GeekInterview.com
Series: Subject: Topic:
Question: 51 of 177

Why GenericServlet is an abstract class ?

Asked by: Interview Candidate | Asked on: Dec 12th, 2006
Showing Answers 1 - 9 of 9 Answers
Kethams

Answered On : Dec 14th, 2006

To prevent creating of objects

  
Login to rate this answer.
Deepak Sharma

Answered On : Dec 19th, 2006

GenericServlet r abstract because no one can instansiate the object and it is a parent class for servlet.

thanx

  
Login to rate this answer.
Rahul Gupta

Answered On : Dec 20th, 2006

GenericServlet class is abstract because there is a method called service() which is public abstract void. and service() must be override, service() method defines what type of protocol is used for request. another thing is that according to Java specifiation those classes have abstract methods must declared abstract.abstract methods have no body only prototype.

Yes  1 User has rated as useful.
  
Login to rate this answer.
wrushasen dakhane

Answered On : Dec 20th, 2006

Also I would like to add one thing that, if in future some body wants to access it with some other protocol type then by extending the class it is quite possible.

  
Login to rate this answer.
A.Naresh Kumar Reddy

Answered On : Jan 8th, 2007

GenericServlet is a convenient abstract class for defining Servlets. Servlets which need more control than HttpServlet can extend GenericServlet.

To write a generic servlet, you need only override the abstract service method.

For that reason GenericServlet is an abstract class

  
Login to rate this answer.
sunil.yadav

Answered On : Jan 31st, 2007

View all answers by sunil.yadav

According to OOPs concept there has to be some point or abstraction, above which one can extends his/her functionallity as per requirement. GenericServlet provides the common architecture above which one can design his/her servlet as per requirement, henceforth no object creation is allowed for the GenericServlet.

  
Login to rate this answer.
A.Naresh Kumar Reddy

Answered On : Mar 8th, 2007

GenericServlet is a convenient abstract class for defining Servlets. Servlets which need more control than HttpServlet can extend GenericServlet.

To write a generic servlet, you need only override the abstract service method.

For that reason GenericServlet is an abstract class

  
Login to rate this answer.
dhruv_saksena

Answered On : Mar 14th, 2008

View all answers by dhruv_saksena

GenericServlet is an abstract class because its upto the user how he wants it to use the life-cycle methods of the servlet and also the server needs to make sure that all the life cycle methods of the servlets have to be implemented.So if a class is extending GenericServlet it is bound to implement all of its abstract all of its methods.

If we had made GenericServlet a non-abstract class then user is not forced to implement all the life cycle methods.Also there are many protocols so in future an new protocol comes up it has just to override these methods.

Dhruv

  
Login to rate this answer.
Avijit Chowdhury

Answered On : Nov 10th, 2011

when you are overriding any abstract class, you have to override all the methods of that class.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.