Streams and Binary Input/Output Full Test Bank Ch.20 - Big Java Early Objects 5e Complete Test Bank by Cay S. Horstmann. DOCX document preview.

Streams and Binary Input/Output Full Test Bank Ch.20

Course Title: Big Java, Early Objects

Chapter Number: 20 Streams and Binary Input/Output

Question type: Multiple Choice

1) Which file storage method is in human-readable form?

a) binary

b) object

c) text

d) byte

Title: Which file storage method is in human-readable form?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

2) Which file storage method stores data in bytes?

a) binary

b) object

c) text

d) byte

Title: Which file storage method stores data in bytes?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

3) Which class is used for input of binary data?

a) Reader

b) Writer

c) InputStream

d) OutputStream

Title: Which class is used for input of binary data?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

4) Which class is used for input of text data?

a) Reader

b) Writer

c) InputStream

d) OutputStream

Title: Which class is used for input of text data?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

5) Which class is used for input of text data from a file?

a) RandomAccessFile

b) FileWriter

c) FileInputStream

d) Scanner

Title: Which class is used for input of text data from a file?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

6) Which line completes this code fragment so it creates a text file called "mychars.txt" and writes the characters 'A', 'B', and 'C' into the file?

_____________________

fw.write('A');

fw.write('B');

fw.write('C');

a)

PrintWriter fw = new PrintWriter("mychars.txt");

b)

FileOutputStream fw = new FileOutputStream("mychars.txt");

c)

File fw = new File("mychars.txt");

d)

PrintStream fw = new PrintStream("mychars.txt");

Title: Complete code fragment to create a text file and write characters to it

Difficulty: Medium

Section Reference 1: 20.1 Readers, Writers, and Streams

7) Which line completes this code fragment to define a text file named txtfile for reading?

____________________________________________________

String line = scan.nextLine();

a)

Reader scan = new Reader(new File("txtfile"));

b)

FileReader scan = new File("txtfile");

c)

Scanner scan = new Scanner(System.in);

d)

Scanner scan = new Scanner(new File("txtfile"));

Title: Complete code fragment to define a text file for reading

Difficulty: Medium

Section Reference 1: 20.1 Readers, Writers, and Streams

8) You use _________ and FileOutputStream objects to write data to a disk file in text or binary form respectively.

a) FileReader

b) PrintWriter

c) OutputStreamWriter

d) ObjectOutputStream

Title: Use _____ and FileOutputStream objects to write data to a file in text or binary form.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

9) When constructing a Scanner from a File object, the Scanner automatically constructs a ___________.

a) InputStream

b) FileInputStream

c) FileReader

d) PrintWriter

Title: When constructing a Scanner from a File object, the Scanner automatically constructs a ___________.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

10) Which is an advantage of storing numbers in binary format?

I fast access

II less storage needed

III easy to read in a text editor

a) I

b) III

c) I and II

d) I and III

Title: Which is an advantage of storing numbers in binary format?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

11) To read text data from a disk file, you should create a(n) ____________________ object.

a) Scanner

b) PrintWriter

c) InputStream

d) OutputStream

Title: To read text data from a file, create a ______ object.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

12) In text format, data items are represented in human-readable form, as a sequence of ____________________.

a) integers

b) bytes

c) characters

d) strings

Title: In text format, data items are represented as a sequence of ____.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

13) Which of the following statements enables you to write output to a text file?

a) PrintWriter out = new PrintWriter();

b) PrintWriter out = new PrintWriter("output.txt");

c) FileReader reader = new FileReader("input.txt");

d) Scanner in = new Scanner(reader);

Title: Which statement enables you to write output to a text file?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

14) A byte is composed of ____ bits and can denote ____ values.

a) 2, 19

b) 4, 256

c) 8, 256

d) 8, 1024

Title: A byte is composed of ____ bits and can denote ____ values.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

15) In Java, the simplest mechanism for reading text is to use the ____ class.

a) ReadWrite

b) Scanner

c) PrintWriter

d) Serializable

Title: The simplest mechanism for reading text is to use the ____ class.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

16) Readers and writers access sequences of ____.

a) bytes

b) characters

c) files

d) streams

Title: Readers and writers access sequences of ____.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

17) Streams access sequences of ____.

a) characters

b) files

c) strings

d) bytes

Title: Streams access sequences of ____.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

18) If you store information in binary form, as a sequence of bytes, you will use the ____ class(es) and their subclasses.

a) InputStream and OutputStream

b) Serializable

c) PrintWriter

d) Reader and Writer

Title: To store binary data, use the ____ class(es).

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

19) Which of the following reads binary data from a disk file?

a) PrintWriter text = new PrintWriter("input.bin");

b) FileReader text = new FileReader("input.bin");

c) FileInputStream inputStream = new FileInputStream("input.bin");

d) FileWriter text = new FileWriter("input.bin");

Title: Which statement reads data from a binary file?

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

20) The ____ class is used when writing text files.

a) PrintWriter

b) InputStream

c) JFileChooser

d) Serializable

Title: The ____ class is used when writing text files.

Difficulty: Easy

Section Reference 1: 20.1 Readers, Writers, and Streams

21) The FileInputStream read method reads binary data. What type is actually returned from a call to read?

a) int

b) char

c) String

d) byte

Title: What type is returned from a call to FileInputStream.read?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

22) What is returned by the read method when a FileInputStream has reached the end of the file?

a) -1

b) -2

c) ‘\n’

d) 0

Title: What is returned when FileInputStream.read reaches the end of file?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

23) How many bytes does the read method in the FileInputStream class actually get from the file?

a) 1

b) 2

c) 4

d) 8

Title: How many bytes does FileInputStream.read get from the file?

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

24) You cannot read a(n) ____________________ file with a text editor.

a) random

b) serial

c) sequential

d) binary

Title: You cannot read a ____ file with a text editor.

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

25) How many bytes does the read method in the FileInputStream class actually return to the program call?

a) 1

b) 2

c) 4

d) 8

Title: How many bytes does FileInputStream.read return to the program call?

Difficulty: Hard

Section Reference 1: 20.2 Binary Input and Output

26) How many bytes does the read method in the InputStream class get from the file?

a) 1

b) 2

c) 4

d) 8

Title: How many bytes does InputStream.read get from the file?

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

27) How many bytes does the read method in the InputStream class actually return to the program call?

a) 1

b) 2

c) 4

d) 8

Title: How many bytes does the read method in the InputStream class actually return to the program call?

Difficulty: Hard

Section Reference 1: 20.2 Binary Input and Output

28) What is the result of the following code?

Reader reader = … ; // connect to a file

char ch = reader.read();

a) compiler error

b) 1 byte is read from the file

c) 2 bytes are read from the file

d) 4 bytes are read from the file

Title: What is the result of the code?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

29) Which statement is true regarding the following code, assuming reader is a FileInputStream object?

char ch = (char) reader.read();

I you cannot determine if you have reached the end of input

II this code will throw an exception if we are at the end of input

III read returns an int, so the cast is illegal

a) I

b) II

c) III

d) I and II

Title: Which statement is true regarding a FileInputStream object?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

30) If you write a simple Student class, what must you do in order to write Student objects to an ObjectOutputStream?

a) Code a write method.

b) Make all class variables primitive.

c) Implement Serializable.

d) Implement Streamable.

Title: What must you do in order to write Student objects to an ObjectOutputStream?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

31) What is the highest value for a signed (negative and positive) byte?

a) 127

b) 128

c) 255

d) 256

Title: What is the highest value for a signed (negative and positive) byte?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

32) What is the lowest value for a signed (negative and positive) byte?

a) -127

b) -128

c) -255

d) -256

Title: What is the lowest value for a signed (negative and positive) byte?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

Section Reference 2: Common Error 20.1

33) If you want to process text data from a file, which keyword do you look for in classes that specialize in doing that?

a) text

b) serializable

c) binary

d) reader

Title: Which keyword do you look for in classes that specialize in processing text data from a file?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

Section Reference 2: How To 20.1

34) If we read a byte and the value represents an international character equal to 133 using an InputStream object, what is true about the int value we will read?

a) It will be 133.

b) It will be -133.

c) It will be some negative value.

d) It will be some positive value.

Title: If we read a byte equal to 133 using an InputStream, what is true about int value read?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

Section Reference 2: Common Error 20.1

35) Caesar cipher uses a shift of each character by a key with a value between 1 and 255. An a with a shift equal to 3 becomes a d. A z would become a c, wrapping around the alphabet. Which is the encryption of shadow for a key = 3?

a) ukdgry

b) vkdgrz

c) adowsha

d) vjegrz

Title: Which is the Caesar encryption of shadow for a key = 3?

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

36) Caesar cipher uses a shift of each character by a key with a value between 1 and 255. An a with a shift equal to 3 becomes a d. A z would become a c, wrapping around the alphabet. Which is the encryption of picture for a key = -3?

a) erutcip

b) ngahspc

c) mfzqrob

d) urepict

Title: Which is the Caesar encryption of picture for a key = -3?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

37) Caesar cipher uses a shift of each character by a key with a value between 1 and 255. An a with a shift equal to 3 becomes a d. A z would become a c, wrapping around the alphabet. Which key should you use to encrypt picture into mfzqrob?

a) 3

b) 19

c) -3

d) -19

Title: Which is the Caesar encryption of picture for a key = -3?

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

38) Caesar cipher uses a shift of each character by a key with a value between 1 and 255. An a with a shift equal to 3 becomes a d. A z would become a c, wrapping around the alphabet. Which is the decryption of exmmv for a key = -3?

a) cvkkt

b) atiir

c) bujjs

d) happy

Title: Which is the Caesar decryption of exmmv for a key = -3?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

39) Caesar cipher uses a shift of each character by a key with a value between 1 and 255. An a with a shift equal to 3 becomes a d. For the encrypt method below, select the correct body. Assume the key shift property is accessible to the method.

public int encrypt(int b) { __________ }

a) return (b + key);

b) return (b + key % 26);

c) return (b + key) % 256);

d) return (b + 26 % key);

Title: For the CaesarCipher.encrypt method below, select the correct body.

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

40) Caesar cipher uses a shift of each character by a key with a value between 1 and 255. An a with a shift equal to 3 becomes a d. For the decrypt method below, select the correct body. Assume the key shift property is accessible to the method.

public int decrypt(int b) { ________ }

a) return (b + key);

b) return (b - key % 26);

c) return (b - key) % 256);

d) return (b - key);

Title: For the decrypt method below, select the correct body.

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

41) The values of the byte type range from ____ to ____.

a) 0, 255

b) 0, 256

c) -128, 128

d) -128, 127

Title: The values of the byte type range from ____ to ____.

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

Section Reference 2: Common Error 20.1

42) In Java, the byte type is a(n) ____ type.

a) positive

b) signed

c) negative

d) unsigned

Title: The byte type is a ____ type.

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

Section Reference 2: Common Error 20.1

43) Why does FileInputStream override the read method from its superclass InputStream?

a) In order to return a char.

b) In order to read binary data.

c) To read data from a file.

d) To check for end of file.

Title: Why does FileInputStream override the InputStream.read method?

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

44) You would need a Caesar cipher with a shift of __________ to decrypt the following text, T U V W X Y Z A B C D E F G H I J K L M N O P Q R S, so that it reads A B C D E F G H I J K L M N O P Q R S T U V W X Y Z.

a) 7

b) 20

c) 19

d) -19

Title: You need a Caesar cipher with a shift of ____ to decrypt this text to ...

Difficulty: Medium

Section Reference 1: 20.2 Binary Input and Output

45) In ____________ file access, the file is processed starting from the beginning.

a) random

b) serial

c) sequential

d) binary

Title: ____ file access processes a file starting at the beginning.

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

46) Which code stores an array buttonArray of JButton objects in a file named buttonFile? We ignore exceptions in this problem.

a)

ObjectStream os = new ObjectStream(new FileStream("buttonFile");

os.writeObject(buttonArray);

b)

ObjectOutputStream oos = new ObjectOutputStream(

new FileOutputStream("buttonFile");

oos.writeObject(buttonArray);

c)

ObjectOutputStream oos = new ObjectOutputStream(

new FileOutputStream("buttonFile");

oos.writeObject(buttonArray[0]);

d)

ObjectOutputStream oos = new ObjectOutputStream("buttonFile");

oos.writeObject(buttonArray);

Title: Which code stores an array buttonArray of JButton objects in a file named buttonFile?

Difficulty: Medium

Section Reference 1: 20.4 Object Streams

47) The ______ method returns an integer, either -1 (at the end of the file) or a byte between 0 and 255.

a) RandomAccessFile.seek

b) InputStream.read

c) Scanner.next

d) Reader.length

Title: The _____ method returns an integer, either -1 or a byte..

Difficulty: Easy

Section Reference 1: 20.2 Binary Input and Output

48) In which of the following modes can a RandomAccessFiles be opened?

I “r”

II “rw”

III “w”

a) I

b) II

c) I and II

d) I and III

Title: In which of the following modes can a RandomAccessFiles be opened?

Difficulty: Medium

Section Reference 1: 20.3 Random Access

49) What do we call the measure in bytes of the file pointer from the beginning of a RandomAccessFile?

a) latency

b) offset

c) size

d) seek

Title: What do we call the measure in bytes from the begining to the file pointer?

Difficulty: Medium

Section Reference 1: 20.3 Random Access

50) Which is not a method in the RandomAccessFile class?

a) getFilePointer

b) seek

c) scan

d) length

Title: Which is not a method in the RandomAccessFile class?

Difficulty: Medium

Section Reference 1: 20.3 Random Access

51) Which method in the RandomAccessFile class provides for random access?

a) move

b) seek

c) goto

d) offset

Title: Which method in the RandomAccessFile class provides for random access?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

52) Which of the following classes are used with data in binary form?

I FileInputStream

II FileReader

III RandomAccessFile

a) I

b) I and II

c) I and III

d) II and III

Title: Which of the following classes are used with data in binary form?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

53) Given a RandomAccessFile that stores a set of records of class MyData, each needing MyData.RECORD_SIZE bytes for storage, which expression gets the offset to the beginning of the 25th record?

a) MyData.RECORD_SIZE * 25

b) MyData.RECORD_SIZE * 24

c) MyData.RECORD_SIZE++

d) MyData.RECORD_SIZE + 25

Title: Given a RandomAccessFile which expression gets the offset of the 25th record?

Difficulty: Medium

Section Reference 1: 20.3 Random Access

54) Assume we have a RandomAccessFile object, file, which stores a set of records of class MyData, each needing MyData.RECORD_SIZE bytes for storage. If the file pointer is currently on the 24th record, which expression gets to the offset of the beginning of the 25th record?

a) MyData.RECORD_SIZE + 1

b) MyData.RECORD_SIZE + file.getFilePointer()

c) MyData.RECORD_SIZE * 2

d) file.getFilePointer()

Title: Which expression gets to the offset of the beginning of the 25th record?

Difficulty: Medium

Section Reference 1: 20.3 Random Access

55) Assume we have a RandomAccessFile object, file, which stores a set of records of class MyData, each needing MyData.RECORD_SIZE bytes for storage. Which expression calculates the number of records in the file?

a) MyData.RECORD_SIZE * file.length()

b) MyData.RECORD_SIZE + file.getFilePointer()

c) file.seek(0L) / MyData.RECORD_SIZE

d) file.length() / MyData.RECORD_SIZE

Title: Which expression calculates the number of records in the file?

Difficulty: Medium

Section Reference 1: 20.3 Random Access

56) Assume we have a RandomAccessFile object, file, which stores a set of records of class MyData. The size of each record is MyData.RECORD_SIZE. Assume MyData has read and write methods, both of which take a RandomAccessFile as an argument. Method write writes the object at the current location. Method read reads the record from current location of the file into the object. If we are currently at the beginning of the 25th record, which code correctly modifies the 25th record by changing its color to Color.yellow through the setColor method?

a)

myData.read(file);

myData.setColor(Color.yellow);

myData.write(file);

b)

myData.read(file);

myData.setColor(Color.yellow);

file.seek(file.getFilePointer());

myData.write(file);

c)

myData.read(file);

myData.setColor(Color.yellow);

file.seek(file.getFilePointer() + MyData.RECORD_SIZE);

myData.write(file);

d)

long loc = file.getFilePointer();

myData.read(file);

myData.setColor(Color.yellow);

file.seek(loc);

myData.write(file);

Title: Which code modifies the 25th record through the setColor method?

Difficulty: Hard

Section Reference 1: 20.3 Random Access

57) Assume we have a RandomAccessFile object, file, that stores a set of records of class MyData. The size of each record is MyData.RECORD_SIZE. Assume MyData has read and write methods both of which take a RandomAccessFile as an argument. Method write writes the object at the current location. Method read reads the record from current location of the file into the object. If we are currently at the beginning of the 1st record, which code correctly modifies the 2nd record by changing its color to Color.red through the setColor method?

a)

file.seek(MyData.RECORD_SIZE);

myData.read(file);

myData.setColor(Color.red);

file.seek(MyData.RECORD_SIZE);

myData.write(file);

b)

myData.read(file);

myData.read(file);

myData.setColor(Color.red);

myData.write(file);

c)

myData.read(file);

myData.setColor(Color.red);

file.seek(file.getFilePointer() + MyData.RECORD_SIZE);

myData.write(file);

d)

long loc = file.getFilePointer();

myData.read(file);

myData.setColor(Color.red);

file.seek(loc);

myData.write(file);

Title: Which code correctly modifies the 2nd record?

Difficulty: Hard

Section Reference 1: 20.3 Random Access

58) Which is not a method available in the RandomAccessFile class?

a) open

b) readInt

c) readDouble

d) close

Title: Which is not a method available in the RandomAccessFile class?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

59) __________ access allows file access at arbitrary locations, without first reading the bytes preceding the access location.

a) Random

b) Serial

c) Sequential

d) Binary

Title: What type of access allows file access at arbitrary locations?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

60) In Java, you use a(n) ____________ object to access a file and move its file pointer.

a) Stream

b) Serializable

c) SequentialAccessFile

d) RandomAccessFile

Title: Use a _____ object to access a file and move a file pointer.

Difficulty: Easy

Section Reference 1: 20.3 Random Access

61) When storing numbers in a file with fixed record sizes, it is easier to store them in __________ format.

a) character

b) text

c) binary

d) serializable

Title: In a file with fixed record sizes, it is easier to store numbers in ____ format.

Difficulty: Easy

Section Reference 1: 20.3 Random Access

62) Based on the code below, the statement that would move the file pointer to byte n counted from the beginning of the file is ___________________.

RandomAccessFile test = new RandomAccessFile("record.bat", "r");

a) test.getFilePointer(n);

b) test.getFilePointer();

c) test.seek(n);

d) test.length() – n;

Title: Which statement would move the file pointer to byte n?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

63) Use a ____ object to access a file and move a file pointer.

a) Random

b) RandomAccess

c) RandomAccessFile

d) System.in

Title: Use a ____ object to access a file and move a file pointer.

Difficulty: Easy

Section Reference 1: 20.3 Random Access

64) The readInt and writeInt methods of the RandomAccessFile class read and write integers as ____ quantities.

a) two-byte

b) four-byte

c) six-byte

d) eight-byte

Title: RandomAccessFile.readInt/writeInt read/write integers as ____ quantities.

Difficulty: Easy

Section Reference 1: 20.3 Random Access

65) The readDouble and writeDouble methods of the RandomAccessFile class, process double precision floating-point numbers as ____ quantities.

a) two-byte

b) four-byte

c) eight-byte

d) ten-byte

Title: RandomAccessFile.readDouble/writeDouble process floating-point numbers as ____ quantities.

Difficulty: Easy

Section Reference 1: 20.3 Random Access

66) A file pointer is a position in a random access file. Because files can be very large,

the file pointer is of type _______.

a) double

b) byte

c) int

d) long

Title: A file pointer is of type _______.

Difficulty: Easy

Section Reference 1: 20.3 Random Access

67) Which of these classes access sequences of characters?

I readers

II writers

III streams

a) I

b) II

c) I and II

d) II and III

Title: Which of these classes access sequences of characters?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

68) Which method moves the file pointer in a RandomAccessFile?

a) seek

b) length

c) getFilePointer

d) close

Title: Which method moves the file pointer in a RandomAccessFile?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

69) Which code moves the file pointer to the middle of a RandomAccessFile object, file?

a) file.seek(file.length() / 2)

b) file.seek(file.length())

c) file.seek(0L)

d) file.seek(file.getFilePointer() / 2)

Title: Which code moves the file pointer to the middle of a RandomAccessFile?

Difficulty: Easy

Section Reference 1: 20.3 Random Access

70) Which of the following cannot be serialized?

I ArrayList<String>

II String

III Integer

a) I

b) II and III

c) III

d) All can be serialized

Title: Which of the following cannot be serialized?

Difficulty: Medium

Section Reference 1: 20.4 Object Streams

71) In which package are most classes for file processing found?

a) java.file

b) java.inputoutput

c) java.io

d) java.stream

Title: In which package are most classes for file processing found?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

72) Objects are saved in ___________ format in object streams.

a) binary

b) character

c) stream

d) integer

Title: Objects are saved in____ format in object streams.

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

73) The two IO classes used for serialization are _______ and ________.

a) Reader, Writer

b) ObjectInputStream, ObjectOutputStream

c) Scanner, PrintWriter

d) FileReader, FileWriter

Title: The two IO classes used for serialization are ___ and ___.

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

74) Which methods are not in the Serializable interface?

I readObject

II writeObject

III serializeObject

a) I

b) I and II

c) II and III

d) I, II, and III

Title: Which methods are not in the Serializable interface?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

75) Which of the following classes are related through inheritance?

I InputStream

II InputStreamReader

III ObjectInputStream

a) I and II

b) I and III

c) II and III

d) I, II and III

Title: Which of the follow classes are related through inheritance?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

76) Which interface allows classes to be written to an ObjectOutputStream?

a) Objective

b) Streaming

c) Serializable

d) Objectifiable

Title: Which interface allows classes to be written to an ObjectOutputStream?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

77) How many methods are required to implement the Serializable interface?

a) 3

b) 2

c) 1

d) 0

Title: How many methods are required to implement the Serializable interface?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

78) Every object is assigned a serial number on the stream. What might be the result if the same object is saved twice?

a) The object will have two serial numbers.

b) Only the serial number is written out the second time.

c) A performance decrease.

d) Running out of serial numbers.

Title: What might be the result if the same object is saved twice to the stream?

Difficulty: Medium

Section Reference 1: 20.4 Object Streams

79) If serializing object obj requires 12 bytes, how many bytes are required to serialize obj 3 times?

a) 12 bytes plus 3 serial numbers of obj

b) 36 bytes

c) 12 bytes

d) 12 bytes plus 2 serial numbers of obj

Title: If serializing obj uses 12 bytes, how many bytes are required to serialize it 3 times?

Difficulty: Medium

Section Reference 1: 20.4 Object Streams

80) Objects saved to an object stream must belong to classes that:

a) implement the Serializable interface.

b) are RandomAccessFile objects.

c) are abstract.

d) implement the ObjectInputStream interface.

Title: Objects saved to an object stream must belong to classes that:

Difficulty: Medium

Section Reference 1: 20.4 Object Streams

81) What type is returned from a call to the ObjectInputStream.readObject method when reading a String from an object stream?

a) Object

b) String

c) char

d) ObjectStream

Title: What type is returned by the ObjectInputStream.readObject method when reading a String?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

82) If we want to write objects to a file, what type of object should be passed to the ObjectOutputStream constructor?

a) ObjectStream

b) FileStream

c) FileOutputStream

d) ObjectInputStream

Title: To write objects to a file, what should be passed to the ObjectOutputStream constructor?

Difficulty: Easy

Section Reference 1: 20.4 Object Streams

Document Information

Document Type:
DOCX
Chapter Number:
20
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 20 Streams and Binary Input/Output
Author:
Cay S. Horstmann

Connected Book

Big Java Early Objects 5e Complete Test Bank

By Cay S. Horstmann

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party