• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can such a situation arise in the real exam??

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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."
 
Enthuware Software Support
Posts: 4810
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic