Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Module 10 Mastery Check

wolvesled edited this page Sep 16, 2013 · 1 revision
  1. Why does Java define both byte and character streams? Answer: byte stream for low level support and legacy uses, character stream for internationalization because it is unicode encoded.
  2. Even though console input and output is text-based, why does Java still use byte streams for this purpose?
  3. Show how to open a file for reading bytes. Answer: FileInputStream fin = new FileInputStream("filename.ext")
  4. Show how to open a file for reading characters. Answer: DataInputStream fin = new DataInputStream("filename.ext")
  5. Show how to open a file for random access I/O. Answer: RandomAccessFile raf = new RandomAccessFile("filename.ext", access)
  6. How can you convert a numeric string such as "123.23" into its binary equivalent?
  7. Write a program that copies a text file. In the process, have it convert all spaces into hyphens. Use the byte stream file classes.
  8. Rewrite the program described in question 7 so that it uses the character stream classes.
  9. What type of stream is System.in? Answer: InputStream
  10. What does the read() method of InputStream return when the end of the stream is reached? Answer: -1
  11. What type of stream is used to read binary data? Answer: DataInputStream and DataOutputStream
  12. Reader and Writer are at the top of the ____________class hierarchies. Answer: character stream

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.