Here is the question I had answered wrongly from one of the mock exams fron Enthuware.
Following is the code for TestServlet (See exhibit). Assuming that it is not preloaded or preinitialized, which of the given statements about it are correct?
And here are the options.
A. For any and every HTTP request, at the most 2 of its methods will be called.
B. For any and every request, atleast 1 of its methods will be called.
C. For any and every request, service() will be called.
D. For an HTTP PUT request, none of its methods will be called
E. For an HTTP PUT request, it'll throw an exception.
I choose CE as answers, however Enthuware says correct answers are BC.
I would like to know why option E is not correct since the code doesn't override doPut() a run time exception will occur mentioning that doPut is not supported. In the explanation Enthuware says, "HttpServlet also provides default implementation for all the doXXX methods. So even if you do not implement these methods there is no compliation error."
But I remember, when we don't override doPost and post a request the servlet throws run time exception saying that doPost not supported.
Please correct me if I am wrong.
Sai Surya, SCJP 5.0, SCWCD 5.0, IBM 833 834
http://sai-surya-talk.blogspot.com, I believe in Murphy's law.