• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock question

 
Luis Torres
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the question following:

For a given ServletResponse, which two retrieve an object for writing text data?
A. response.getWriter()
B. response.getOutputStream()
C. response.getOutputWriter()
D. response.getWriter().getOutputStream()
E. response.getWriter(Writer.OUTPUT_TEXT)

I only see one alternative correct(obviously letter A), but the question asks for 2 answers.

Thanks
 
Vishwas Gupta
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the stress is on writing "text" data, then getting PrintWriter is only option. So I think you are correct.
 
Gorkal Raghavendra
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Luis Torres:
I have the question following:

For a given ServletResponse, which two retrieve an object for writing text data?
A. response.getWriter()
B. response.getOutputStream()
C. response.getOutputWriter()
D. response.getWriter().getOutputStream()
E. response.getWriter(Writer.OUTPUT_TEXT)

I only see one alternative correct(obviously letter A), but the question asks for 2 answers.

Thanks



response.getWriter() and
response.getOutputStream()
 
John Pearson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since C, D, and E all use nonexistent methods, B has to be the other correct answer. I suppose since getOutputStream returns a ServletOutputStream, and that has methods that include print(String s) and println(String s), it's certainly possible to write text using a stream.

So, while A is clearly the best choice for writing text, B is also correct.
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The correct options are:
A. response.getWriter(): Returns a PrintWriter object that can send character text to the client.
B. response.getOutputStream():Returns a ServletOutputStream suitable for writing binary data in the response.

So getwriter() seems to be perfect match ,as its asking for text to be written.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic