Java I/O Fundamentals Flashcards

1
Q

What is the result of the expression “10” + “10”?

A

1010

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which System method retrieves a Console instance?

A

console

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which keyword indicates an instance field should be omitted during serialization?

A

transient

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which System method resets the System.out stream from the console?

A

setOut

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which Console method ensures secure entry by suppressing the echo of characters and returning a char array that can be overwritten?

A

readPassword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the three built-in streams provided by Java?

A

System.in, System.out, System.err

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which fields are omitted during serialization?

A

static and instance fields with the transient keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which marker interface indicates a class can be written to and read from a stream?

A

Serializable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What determines whether an additive operator performs arithmetic addition or string concatenation?

A

The data type of its operands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When performing a read operation, which value indicates an end of file?

A

-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which method of the BufferedReader class ignores and discards a specified number of characters?

A

skip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Is FilterReader an interface, abstract class, or concrete class?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What classes implement a getChannel method?

A

The getChannel() method is implemented by only the RandomAccessFile and FileInputStream classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a FileChannel?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Is Closeable an Interface, Abstract Class, or Concreate Class

A

Interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is interface does Closeable extend?

A

AutoCloseable

17
Q

What is a key difference between Closeable and AutoCloseable?

A

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.

18
Q

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?

A

No; inherited fields are only Serialized if the super class is declared with the marker interface Serializable.

19
Q

What does the RandomAccessFile seek method do?

A

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.

20
Q

Are the standard streams character streams, byte streams, or a combination of both?

A

All three are byte streams.

21
Q

Does FileWriter have a constructor for (String, boolean)?

A

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

22
Q

What is the correct way to use a BufferedReader with the System.in stream?

A

TBD

23
Q

Explain the mark(int i) method in BufferedReader

A

TBD