Discussion
Which Servlet life-cycle method is called only once ?
Answer: A
The keyed answer is init().
The servlet container calls init() exactly once, after it creates the servlet object and before the first request, to let the servlet set itself up. service() (the printed option reads services()) and the handlers doGet() and doPost() run once for every request.
One caution: destroy() is also called only once, when the container removes the servlet. The question does not exclude it, but the key and the usual textbook answer to 'called only once' is init(), the one-time initialisation method, so that is the answer given.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development