Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Servlet-Interview-Questions HttpServlet is declared abstract
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vijay Kumar
HttpServlet is declared abstract
2 Answer(s)      4 years and 2 months ago
Posted in : Servlet Interview Questions


Explain why HttpServlet is declared abstract ?


Advertisement
View Answers

November 2, 2010 at 3:14 PM


The Constructor HttpServlet() does nothing because this is an abstract class. Default implementations in a few Java classes like HttpServlet don?t really do anything. Hence, they need to be overridden.

Usually one of the following methods of HttpServlet must be overridden by a subclass:

  • doGet, if the servlet supports HTTP GET requests
  • doPost, HTTP POST requests
  • doPut, HTTP PUT requests
  • doDelete, HTTP DELETE requests
  • init and destroy, to manage resources
  • getServletInfo, to provide information


May 6, 2013 at 7:44 PM


Hi, 1)Suppose HttpServlet Class isn't declared as abstract,Still there is no use of creating the object of HttpServlet class because all the method present inside the HttpServlet mostly does nothing. 2)Declaring HttpServlet as abstract,provides a signal to the Developer that the class has no practical use, and don't create the object of this class. rather have your own implementation for your service. 3)you can override any method from doxxx or service() method for your Servlet,and you can have own business logic.not necessary to override all the methods of HttpServlet. any corrections are welcomed,let me know if i am wrong anywhere. Thanks Balu



Related Tutorials/Questions & Answers:
HttpServlet is declared abstract
HttpServlet is declared abstract  Explain why HttpServlet is declared abstract
variables and methods declared in abstract class is abstract or not
variables and methods declared in abstract class is abstract or not  variables and methods declared in abstract class is abstract
Advertisements
Can a abstract class be declared final?
Can a abstract class be declared final?   Hi, Can a abstract class be declared final? Thanks
Java httpservlet
Java httpservlet       HttpServlet class is an abstract class defined in "javax.servlet.http"...-independent servlet but HttpServlet class provides an HTTP protocol specific
Difference between GenericServlet and HttpServlet
and HttpServlet. GenericServlet is an abstract class that extends java.lang.Object while HttpServlet is an abstract class that extends GenericServlet... interfaces while HttpServlet implements java.io.Serializable. HttpServlet is a subclass
Java Abstract Class
Java Abstract Class       An abstract class is a class that is declared by using the abstract keyword. It may or may not have abstract methods. Abstract classes cannot be instantiated
Methods of HttpServlet
Methods of HttpServlet  What are methods of HttpServlet
HttpServlet protocols
HttpServlet protocols   What are the type of protocols supported by HttpServlet?   It extends the GenericServlet base class and provides an framework for handling the HTTP protocol. So, HttpServlet only supports HTTP
Abstract Class in Java
Abstract class in Java is a class that is declared using abstract keyword.... An abstract method is declared without body but is followed by a semicolon. If we have... into sub classes. Abstract class can be declared as: abstract class
Related to GenericServlet and HttpServlet
Related to GenericServlet and HttpServlet  Que: Http Servlet extends Generic Servlet then Why both GenericServlet and HttpServlet implements Serializable interface ?   GenericServlet and HttpServlet implement
abstract class
abstract class   Explain the concept of abstract class and it?s use with a sample program.   Java Abstract Class An abstract class is a class that is declared by using the abstract keyword. It may or may not have
Can a class be declared as static?
Can a class be declared as static?  Hi, Can a class be declared as static? thanks
Can a class be declared as protected?
Can a class be declared as protected?  Hi, Can a class be declared as protected? thanks   Hi, A class can't be declared as protected. only methods can be declared as protected. http://www.roseindia.net/java
Abstract and Interface
declared in a Java interface is by default final. An abstract class may contain non...Abstract and Interface  What is interface? When time is most suitable for using interface? Why we use interface instead of abstract? What
abstract class
abstract class  Can there be an abstract class with no abstract methods
abstract method
abstract method  Can we have abstract class with no abstract methods
abstract method
abstract method  is final method is in abstract class
Abstract class
Abstract class  what is an Abstract class
Abstract class
Abstract class  Can an abstract class be final
Abstract and Interface
Abstract and Interface  what is the difference between Abstract and Interface accurateatly
abstract method
abstract method  Can a concrete class have an abstract method
HttpServlet reading XML from HttpRequest - XML
HttpServlet reading XML from HttpRequest   Hi , My requirement is 1.Input to the HttpServlet will be the XML sent by upstream as HttpRequest.... HttpServlet should only read the XML from HttpRequest and put it to a string. Can any
Abstract class
Abstract class  j   An Abstract class is a base class which... with an abstract keyword. For more information, visit the following links: http://www.roseindia.net/help/java/a/java-abstract-class.shtml http://www.roseindia.net/java
abstract class
abstract class  abstract class AbstractClass{ } is possible and compile the class or any compile time error occur tell me the answer Blockquote
abstract class
abstract class  what is abstract class .why we use it or what is the need of this class?   Abstract class is like base class which contains abstract method and cannot instantiated.   Please go through
Interface and Abstract class
Interface and Abstract class  Difference between Interface and Abstract class? Give some example   Difference Between Interface and Abstract Class 1)Main difference is methods of a Java interface are implicitly
Abstract class
Abstract class  Calendar cal=Calendar.getInstance() We know that Calendar is an abstract class so it can't be instantiated. So how we can say that cal is an instance of Calendar??? Beginner Question I suppose. Thanks in advace
What if the main() method is declared as private?
What if the main() method is declared as private?  Hi, What if the main() method is declared as private? Thanks   Hi, I have found some reference site for java programming coding for Main() method is declared
Java Abstract Class Example
if the subclass doesn't do so then it must have also declared as abstract. Declaration of abstract class An abstract class should be declared as follows...Java Abstract Class Example In this section we will read about the Abstract
Can a main method be declared final?
Can a main method be declared final?   Hi, Can a main method be declared final? Thanks   Hi, Yes we can. The final method can... be override in a subclass. for more about main method be declared final in Java
Abstract class and abstract method
Some key points about abstract methods are as following An abstract modifier identifies abstract classes and methods An abstract methods cannot be private because it defined in the other class. An abstract methods cannot
 

 

 

DMCA.com