Can we define constructors in Servlet?

Answer Posted / qim2010

One can definitely have constructor in servlet. Even you can
use the constructor in servlet for initialization purpose,
but this type of approach is not so common. You can perform
common operations with the constructor as you normally do.
The only thing is that you cannot call that constructor
explicitly by the new keyword as we normally do. In the case
of servlet, servlet container is responsible for
instantiating the servlet, so the constructor is also called
by servlet container only.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ioc concept?

663


Describe activation process?

2032


What is the difference between a static and a non-static inner class?

571


What’s jboss cache in short?

568


What is colon_pkg_prefixes and what is its use?

1972






Difference between swing and awt?

567


When is the best time to validate input?

571


What is prototype?

586


What are externizable interface?

548


What is difference between object state and behavior?

556


what is Activation Instantinator?

1876


What is the difference between the string and stringbuffer classes?

514


What is synchronization and why is it important?

519


Java is fully object oriented languages or not?

519


Is there a guarantee of uniqueness for entity beans?

540