aspose file tools*
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
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
Author

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?.
Sonir
Rob Ross
Bartender

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.
Rob


Rob
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,
http://java.sun.com/docs/books/tutorial/essential/io/datasinks.html
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="http://www.rajindery.com" 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: 3334
    
    8
Readers/Writers and In(Out)outStreams form two different branches of the i/o classes tree.
All the "readers" (or writers) extend from java.io.Reader (or java.io.Writer), while all input "streams" (or output streams) extend from java.io.InputStream (or java.io.OutputStream).
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.
HTH,
Paul.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can such a situation arise in the real exam??