Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setContentType

 
Ranjani Theyagarajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
response.setContentType("image/gif");

// insert code here...

out.close()

which statement will intialize the out variable?

a) PrintWriter out=response.getWriter();
b) PrintWriter out=response.GetOutputStream();
c) OutputStream out=response.getOutputStream();
d) ServletOutputStream out=response.getServletOutput();


My answer is C. but the given answer is a.
I read somewhere that for binary data need to use getOutPutStream.
Please correct me if am wrong

Thanks,
Ranjani
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the source of this question (mock exam?)? I agree that C should be the answer given that you are setting the content type to be an image.
 
Ranjani Theyagarajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Patrick... I got a PDF from my friend which contains this one..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic