Exam 1z0-900 All QuestionsBrowse all questions from this exam
Question 59

Given the code fragment:

What output will be returned when this servlet is called a GET request?

    Correct Answer: D

    When a servlet receives an HTTP GET request, the `doGet` method is called by the `service` method to handle the request. The `service` method in the `HttpServlet` class is responsible for dispatching requests to the appropriate methods, such as `doGet` for GET requests, `doPost` for POST requests, etc. Since the `doGet` method is explicitly overridden and prints 'Get() method called.', that will be the output when the servlet handles a GET request.

Discussion
orjavaOption: A

Answer A. Override service method disable all other Request handling methods.