Multiple choice technology programming languages

Which codeline must be set before any of the lines that use the PrintWriter

  1. setContentWriter()

  2. setWriter()

  3. setPrintType()

  4. setContentType()

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

The setContentType() method must be called before using PrintWriter because it sets the content type (MIME type) of the response being sent to the client. Once the PrintWriter is obtained and used to write content, the response headers are committed and cannot be modified.