Can we define constructor in Servlet class?

Answer Posted / naveen

yes we can create a constructor
by default JVM calls default constructor.In addition to that if write both default and parameterized constructor then JVM call default one and then parameterized one

hence the ans is yes we hav to write two constuctors
no if write our own constructor one itself

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the key methods that are involved in processing of http servlets?

854


Why do we need a constructor in a servlet if we use the init method?

733


Why do we have servlet listeners?

792


How do you design microservices?

815


How can the referrer and the target urls be used in servlet?

719


What is cgi?

776


What is Request Dispatcher?

1059


What is the difference between a generic servlet and http servlet?

709


Explain how to improve Servlet Performance?

821


What are the steps that are required to handle the multi-threading?

840


Tell us something about servletconfig interface.

761


How can you use a servlet to generate a plain text instead of html?

843


What is the use of servlet context?

739


What is Servlet API used for connecting database?

805


How do you communicate in between Applets and Servlets?

803