To get an object of PrintWriter, we use getWriter() method of class _____________

  1. HttpSession

  2. HttpServletResponse

  3. HttpServletRequest

  4. None


Correct Option: B

AI Explanation

To get an object of PrintWriter in Java, we use the getWriter() method of the HttpServletResponse class.

Option A) HttpSession - This option is incorrect because the getWriter() method is not a method of the HttpSession class.

Option B) HttpServletResponse - This option is correct. The getWriter() method is a method of the HttpServletResponse class, which is used to send a response to the client.

Option C) HttpServletRequest - This option is incorrect because the getWriter() method is not a method of the HttpServletRequest class.

Option D) None - This option is incorrect because the correct answer is option B, HttpServletResponse.

The correct answer is B) HttpServletResponse. This option is correct because the getWriter() method is used to obtain a PrintWriter object to write the response to the client using the HttpServletResponse class.

Find more quizzes: