Lesson 4.1: Advanced Programming Logic Flashcards
What is an I/O stream?
An I/O stream is an abstraction that either produces or consumes information. A stream is linked to a physical device by the Java I/O system. All streams behave in the same manner، even if the actual physical devices they are linked to differ.
What two types of streams do modern versions of Java define?
Modern versions of Java define two types of I/O streams: byte and character. (The original version of Java defined only the byte stream، but character streams were quickly added.)
When are byte streams used over character streams?
Byte streams provide a convenient means for handling input and output of bytes. They are used، for example، when reading or writing binary data. They are especially helpful when working with files.
When are character streams used over byte streams?
Character streams are designed for handling the input and output of characters. They use Unicode and، therefore، can be internationalized. Also، in some cases، character streams are more efficient than byte streams.
At the most basic level، which stream is the only stream used? Why do we still use the other if we only (ultimatley) use both?
At the lowest level، all I/O is still byte-oriented. The character-based streams simply provide a convenient and efficient means for handling characters.
What do InputStream and OutputStream define?
InputStream defines the characteristics common to byte input streams and OutputStream describes the behavior of byte output streams.
What are the byte stream classes by name. Since there are so many، here is a hint: BI،BO،AI،AO،DS،DO،FI،FO،LI،LO، etc. Dont expect to memorize them
The byte stream classes in java.io are shown in Table 10-1. Don’t be overwhelmed by the number of different classes. Once you can use one byte stream، the others are easy to master.
What are the two class hierarchy abstract classes that character streams are topped by?
Character streams are defined by using two class hierarchies topped by these two abstract classes: Reader and Writer.
Which one is which for input and output: reader and writer
Reader is used for input، and Writer is used for output. Concrete classes derived from Reader and Writer operate on Unicode character streams.
What are the several concrete subclasses that are derived from Reader and Writer?
From Reader and Writer are derived several concrete subclasses that handle various I/O situations. In general، the character-based classes parallel the byte-based classes. The character stream classes in java.io are shown in Table 10-2.
By default، what do System.out، System.in، and System.err refer to?
System.out refers to the standard output stream. By default، this is the console. System.in refers to standard input، which is by default the keyboard. System.err refers to the standard error stream، which is also the console by default. However، these streams can be redirected to any compatible I/O device.
What system commands are Input stream and which are output stream?
System.in is an object of type InputStream; System.out and System.err are objects of type PrintStream.
Name 3 (out of the many) InputStream methods and 3 OutputStream methods.
At the top of the byte stream hierarchy are the InputStream and OutputStream classes. Table 10-3 shows the methods in InputStream، and Table 10-4 shows the methods in OutputStream.
For commercial coding، what is the preferred stream orientation? Why
For commercial code، the preferred method of reading console input is to use a character-oriented stream. Doing so makes your program easier to internationalize and easier to maintain.
What are the three different versions of read()
There are three versions of read( )، which are shown here: int read( ) throws IOException int read(byte data[ ]) throws IOException int read(byte data[ ]، int start، int max) throws IOException