Java I/O Fundamentals Flashcards
What is the result of the expression “10” + “10”?
1010
Which System method retrieves a Console instance?
console
Which keyword indicates an instance field should be omitted during serialization?
transient
Which System method resets the System.out stream from the console?
setOut
Which Console method ensures secure entry by suppressing the echo of characters and returning a char array that can be overwritten?
readPassword
What are the three built-in streams provided by Java?
System.in, System.out, System.err
Which fields are omitted during serialization?
static and instance fields with the transient keyword
Which marker interface indicates a class can be written to and read from a stream?
Serializable
What determines whether an additive operator performs arithmetic addition or string concatenation?
The data type of its operands
When performing a read operation, which value indicates an end of file?
-1
Which method of the BufferedReader class ignores and discards a specified number of characters?
skip
Is FilterReader an interface, abstract class, or concrete class?
FilterReader is an abstract class for reading filtered character streams. The abstract class FilterReader itself provides default methods that pass all requests to the contained stream.
What classes implement a getChannel method?
The getChannel() method is implemented by only the RandomAccessFile and FileInputStream classes.
What is a FileChannel?
A file channel is a SeekableByteChannel that is connected to a file. It has a current position within its file which can be both queried and modified. The file itself contains a variable-length sequence of bytes that can be read and written and whose current size can be queried. The size of the file increases when bytes are written beyond its current size; the size of the file decreases when it is truncated. The file may also have some associated metadata such as access permissions, content type, and last-modification time; this class does not define methods for metadata access.
Is Closeable an Interface, Abstract Class, or Concreate Class
Interface
What is interface does Closeable extend?
AutoCloseable
What is a key difference between Closeable and AutoCloseable?
Unlike the close method of Closeable, the AutoCloseable close method is not required to be idempotent. In other words, calling this close method more than once may have some visible side effect, unlike Closeable.close which is required to have no effect if called more than once.
If class B extends class A and class A does not have the Serializable marker and class B does have the Serializable marker will class A’s non-transient fields and non-static fields be serialized with class B?
No; inherited fields are only Serialized if the super class is declared with the marker interface Serializable.
What does the RandomAccessFile seek method do?
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.
Are the standard streams character streams, byte streams, or a combination of both?
All three are byte streams.
Does FileWriter have a constructor for (String, boolean)?
Yes, String is the file name, boolean is used to indicate of the file should be opened in append mode.
String - a File object to write to
boolean - if true, then bytes will be written to the end of the file rather than the beginning
What is the correct way to use a BufferedReader with the System.in stream?
TBD
Explain the mark(int i) method in BufferedReader
TBD