File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can such a situation arise in the real exam?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can such a situation arise in the real exam??" Watch "Can such a situation arise in the real exam??" New topic

Can such a situation arise in the real exam??

sonir shah
Ranch Hand

Joined: Nov 01, 2001
Posts: 435
Question in JQ+...
Which of these can act as a source for an input stream as well as a destination for an output stream?
Select all the 3 correct answers:
A)A network Connection
B)A file
C)A pipe
D)A string
E)Array of chars
Here there are 4 correct answers: ie. A)B)C)E)..But the question asks for 3 correct answers?/
If such case arises in the exam, then what are we supposed to do?.
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
Streams only work with single bytes. A java character is a 2 byte char type; thus, streams can't use arrays of characters as a source or destination.
A Reader or Writer can work with characters, however.
The correct answers for this question are A, B, and C.

SCJP 1.4
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Rob, I agree that E is also a correct answer. I came across this bit of info,
About the following streams: CharArrayReader, CharArrayWriter, ByteArrayInputStream, ByteArrayOutputStream, it states.
"Use these streams to read from and write to memory. You create these streams on an existing array and then use the read and write methods to read from or write to the array."

<a href="" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3634
Readers/Writers and In(Out)outStreams form two different branches of the i/o classes tree.
All the "readers" (or writers) extend from (or, while all input "streams" (or output streams) extend from (or
This question is asking about "streams" and so CharArrayReader, CharArrayWriter are not valid (because they are not streams but reader and writer).
I do not remember the question id but I believe this explanation is given in the question.

Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
I agree. Here's the link:
subject: Can such a situation arise in the real exam??
jQuery in Action, 3rd edition