Multiple choice technology programming languages

To which class or interface do the methods sendError() and sendStatus() belong?

  1. HttpServletRequest

  2. HttpServletResponse

  3. ServletRequest

  4. ServletResponse

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

sendError() and sendStatus() are methods of HttpServletResponse that send HTTP error responses and status codes to the client. HttpServletRequest handles request data, while ServletRequest and ServletResponse are generic interfaces that HttpServlet extends.