Deck 21: Advanced Inputoutputetext Only

Full screen (f)
exit full mode
Question
Which class is used for input of text data?
A.OutputStream
B.Writer
C.InputStream
D.Reader
Use Space or
up arrow
down arrow
to flip the card.
Question
Which class is used for output of binary data to a file?
A.Writer
B.FileOutputStream
C.FileOutput
D.Scanner
Question
Which class is used for input of binary data from a file?
A.FileInput
B.FileInputStream
C.Scanner
D.Reader
Question
Fill in the blank in the following code snippet to create an object for reading binary data from a disk file, named input.bin?
try (______________________________)
{
Process input
}
A.FileReader in = new FileReader("input.bin");
B.FileWriter in = new FileWriter("input.bin");
C.PrintWriter in = new PrintWriter("input.bin");
D.FileInputStream in = new FileInputStream("input.bin");
Question
Which class is used for output of text data to a file?
A.FileWriter
B.FileOutputStream
C.PrintWriter
D.RandomAccessFile
Question
In text format, data items are represented in human-readable form, as a sequence of ____________________.
A.integers
B.strings
C.bytes
D.characters
Question
Which file storage method stores data in bytes?
A.binary
B.byte
C.text
D.object
Question
Which class is used for input of binary data?
A.OutputStream
B.Reader
C.InputStream
D.Writer
Question
Which class is used for input of text data from a file?
A.FileWriter
B.RandomAccessFile
C.FileInputStream
D.Scanner
Question
Which class is used for output of text data?
A.OutputStream
B.Reader
C.InputStream
D.Writer
Question
Streams access sequences of ____.
A.bytes
B.files
C.characters
D.strings
Question
Which class is used for output of binary data?
A.Reader
B.Writer
C.OutputStream
D.InputStream
Question
Which file storage method is in human-readable form?
A.byte
B.text
C.binary
D.object
Question
Which of these classes access sequences of characters?
I readers
II writers
III streams
A.II and III only
B.II only
C.I only
D.I and II only
Question
If you store information in binary form, as a sequence of bytes, you will use the ____ class(es) and their subclasses.
A.Reader and Writer
B.PrintWriter
C.Serializable
D.InputStream and OutputStream
Question
A byte is composed of ____ bits and can denote ____ values.
A.8, 256
B.4, 256
C.8, 1024
D.2, 19
Question
If you access and store information in binary form in files, you will use the ____ class(es).
A.Scanner and PrintWriter
B.PrintStream
C.FileInputStream and FileOutputStream
D.Reader and Writer
Question
The ______ method returns an integer, either -1 (at the end of the file) or a byte between 0 and 255.
A.InputStream.read
B.OutputStream.write
C.Reader.length
D.Scanner.next
Question
Readers and writers access sequences of ____.
A.bytes
B.files
C.streams
D.characters
Question
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 and II only
B.I only
C.III only
D.I and III only
Question
How many bytes does the read method in the FileInputStream class get from the file?
A.1
B.8
C.4
D.2
Question
The values of the byte type range from ____ to ____.
A.-128, 127
B.0, 256
C.-128, 128
D.0, 255
Question
What is the lowest value for a signed (negative and positive) byte?
A.-128
B.-256
C.-255
D.-127
Question
Fill in the blank in the following code snippet to create an object for writing binary data to a disk file, named output.bin?
try (______________________________)
{
Process output
}
A.Writer out = new Writer("output.bin");
B.PrintWriter out = new PrintWriter("output.bin");
C.FileOutputStream out = new FileOutputStream("output.bin");
D.FileWriter out = new FileWriter("output.bin");
Question
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which key should you use to encrypt picture into mfzqrob?
A.19
B.-3
C.-19
D.3
Question
You would need a Caesar cipher with a shift of __________ to decrypt the 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.19
B.7
C.-19
D.20
Question
Which statement is NOT correct about the OutputStream.write method?
A.The method writes an int (4 bytes) to the output stream.
B.The type of the parameter for the method is int.
C.The FileOutputStream class overrides the method to write a single byte to a file.
D.The value of the parameter must be between the values of 0 and 255.
Question
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which is the decryption of exmmv for a key = -3?
A.bujjs
B.atiir
C.cvkkt
D.happy
Question
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which is the encryption of shadow for a key = 3?
A.adowsha
B.vkdgrz
C.vjegrz
D.ukdgry
Question
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 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) % 256);
B.return (b + key % 26);
C.return (b + key);
D.return (b + 26 % key);
Question
Which class has a write method that writes a single byte?
A.Stream
B.PrintWriter
C.OutputStream
D.Writer
Question
What is the highest value for a signed (negative and positive) byte?
A.256
B.127
C.128
D.255
Question
In ____________ file access, the file is processed starting from the beginning.
A.binary
B.random
C.parallel
D.sequential
Question
In Java, the byte type is a(n) ____ type.
A.unsigned
B.positive
C.signed
D.negative
Question
What is returned by the read method when a FileInputStream has reached the end of the file?
A.0
B.-1
C.-2
D.'\n'
Question
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);
C.return (b - key % 26);
D.return (b - key) % 256);
Question
Why does FileInputStream override the read method from its superclass InputStream?
A.In order to read binary data.
B.In order to return a char.
C.To check for end of file.
D.To read data from a file.
Question
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which is the encryption of picture for a key = -3?
A.mfzqrob
B.erutcip
C.urepict
D.ngahspc
Question
You cannot read a ____________________ file with a text editor.
A.serial
B.binary
C.random
D.sequential
Question
The read method of the FileInputStream class reads binary data.What type is actually returned from a call to read?
A.int
B.String
C.byte
D.char
Question
In which of the following modes can a RandomAccessFile be opened?
I r
II rw
III w
A.I and III only
B.I only
C.I and II only
D.II only
Question
Which code moves the file pointer to the middle of a RandomAccessFile object, file?
A.file.seek(file.getFilePointer() / 2)
B.file.seek(file.length() / 2)
C.file.seek(0L)
D.file.seek(file.length())
Question
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 represents the offset to the beginning of the 25th record?
A.MyData.RECORD_SIZE * 2
B.MyData.RECORD_SIZE + file.getFilePointer()
C.MyData.RECORD_SIZE + 1
D.file.getFilePointer()
Question
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 + 25
C.MyData.RECORD_SIZE++
D.MyData.RECORD_SIZE * 24
Question
Which of the following classes are used with data in binary form?
I FileInputStream
II FileReader
III RandomAccessFile
A.I and III only
B.I and II only
C.II and III only
D.I only
Question
Which is NOT a method in the RandomAccessFile class?
A.seek
B.length
C.getFilePointer
D.scan
Question
__________ access allows file access at arbitrary locations, without first reading the bytes preceding the access location.
A.Sequential
B.Serial
C.Random
D.Binary
Question
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.file.length() / MyData.RECORD_SIZE
C.MyData.RECORD_SIZE + file.getFilePointer()
D.file.seek(0L) / MyData.RECORD_SIZE
Question
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? 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?  <div style=padding-top: 35px>
Question
A file pointer is a position in a random access file.Because files can be very large, the file pointer is of type _______.
A.int
B.double
C.long
D.byte
Question
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? 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?  <div style=padding-top: 35px>
Question
Which method in the RandomAccessFile class provides for random access?
A.goto
B.offset
C.seek
D.move
Question
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.length() - n;
C.test.seek(n);
D.test.getFilePointer();
Question
The readInt and writeInt methods of the RandomAccessFile class read and write integers as ____ quantities.
A.two-byte
B.four-byte
C.eight-byte
D.six-byte
Question
When storing numbers in a file with fixed record sizes, it is easier to store them in __________ format.
A.character
B.binary
C.serializable
D.text
Question
The readDouble and writeDouble methods of the RandomAccessFile class, process double precision floating-point numbers as ____ quantities.
A.ten-byte
B.two-byte
C.four-byte
D.eight-byte
Question
Which statement about object streams is NOT correct?
A.Use object input streams to load the saved objects.
B.You must cast the returned result from the readObject method.
C.Any object can be saved to an object output stream.
D.Use object output streams to save all instance variables of an object automatically.
Question
What do we call the measure in bytes of the file pointer from the beginning of a RandomAccessFile?
A.size
B.seek
C.latency
D.offset
Question
Which is not a method available in the RandomAccessFile class?
A.readDouble
B.open
C.readInt
D.close
Question
Which method moves the file pointer in a RandomAccessFile?
A.close
B.seek
C.length
D.getFilePointer
Question
Which of the following cannot be serialized?
I ArrayList
II String
III Integer
A.I only
B.III only
C.II and III only
D.All can be serialized
Question
What type is returned from a call to the ObjectInputStream.readObject method when reading a String from an object stream?
A.String
B.ObjectStream
C.Object
D.char
Question
How many methods are required to implement the Serializable interface?
A.3
B.1
C.0
D.2
Question
Every object is assigned a serial number on the stream.What might be the result if the same object is saved twice?
A.A performance decrease.
B.Running out of serial numbers.
C.The object will have two serial numbers.
D.Only the serial number is written out the second time.
Question
Which interface allows classes to be written to an ObjectOutputStream?
A.Streaming
B.Serializable
C.Objectifiable
D.Objective
Question
In which package are the following types found: Path, Paths, Files?
A.java.io.file
B.java.nio
C.java.nio.file
D.java.io
Question
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
Question
Which code reads an array of Student objects from a file named studentFile.bin? We ignore exceptions in this problem. Which code reads an array of Student objects from a file named studentFile.bin? We ignore exceptions in this problem.  <div style=padding-top: 35px>
Question
Fill in the blank in the following code snippet.
______ myVariable = Paths.get("filename.txt");
A.FileReader
B.File
C.Path
D.FileInputStream
Question
Which of the following classes are related through inheritance?
I InputStream
II InputStreamReader
III ObjectInputStream
A.I, II and III
B.I and III only
C.II and III only
D.I and II only
Question
What type of object describes the location of a file or directory?
A.Path
B.Paths
C.Files
D.Directories
Question
If we want to write objects to a file, what type of object should be passed to the ObjectOutputStream constructor?
A.FileOutputStream
B.ObjectStream
C.ObjectInputStream
D.FileStream
Question
Objects are saved in ___________ format in object streams.
A.integer
B.binary
C.stream
D.character
Question
Which code stores an array studentArray of Student objects in a file named studentFile.bin? We ignore exceptions in this problem. Which code stores an array studentArray of Student objects in a file named studentFile.bin? We ignore exceptions in this problem.  <div style=padding-top: 35px>
Question
Which of the following is NOT a method of the Path type?
A.walk
B.getParent
C.resolve
D.getFileName
Question
The two IO classes used for serialization are _______ and ________.
A.Reader, Writer
B.ObjectInputStream, ObjectOutputStream
C.FileReader, FileWriter
D.Scanner, PrintWriter
Question
Objects saved to an object stream must belong to classes that ______________.
A.implement the ObjectInputStream interface
B.are RandomAccessFile objects
C.implement the Serializable interface
D.are abstract
Question
Which expression returns a String representing the full path to the file filename.txt?
A.Paths.get("filename.txt")
B.Paths.get("filename.txt").toString()
C.Paths.get("filename.txt").toAbsolutePath()
D.Paths.get("filename.txt").toAbsolutePath().toString()
Question
Which methods are not in the Serializable interface?
I readObject
II writeObject
III serializeObject
A.II and III only
B.I, II, and III
C.I and II only
D.I only
Question
If you write a simple Student class, what must you do in order to write Student objects to an ObjectOutputStream?
A.Make all class variables primitive.
B.Implement Streamable.
C.Code a write method.
D.Implement Serializable.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/90
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 21: Advanced Inputoutputetext Only
1
Which class is used for input of text data?
A.OutputStream
B.Writer
C.InputStream
D.Reader
Reader
2
Which class is used for output of binary data to a file?
A.Writer
B.FileOutputStream
C.FileOutput
D.Scanner
FileOutputStream
3
Which class is used for input of binary data from a file?
A.FileInput
B.FileInputStream
C.Scanner
D.Reader
FileInputStream
4
Fill in the blank in the following code snippet to create an object for reading binary data from a disk file, named input.bin?
try (______________________________)
{
Process input
}
A.FileReader in = new FileReader("input.bin");
B.FileWriter in = new FileWriter("input.bin");
C.PrintWriter in = new PrintWriter("input.bin");
D.FileInputStream in = new FileInputStream("input.bin");
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
5
Which class is used for output of text data to a file?
A.FileWriter
B.FileOutputStream
C.PrintWriter
D.RandomAccessFile
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
6
In text format, data items are represented in human-readable form, as a sequence of ____________________.
A.integers
B.strings
C.bytes
D.characters
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
7
Which file storage method stores data in bytes?
A.binary
B.byte
C.text
D.object
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
8
Which class is used for input of binary data?
A.OutputStream
B.Reader
C.InputStream
D.Writer
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
9
Which class is used for input of text data from a file?
A.FileWriter
B.RandomAccessFile
C.FileInputStream
D.Scanner
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
10
Which class is used for output of text data?
A.OutputStream
B.Reader
C.InputStream
D.Writer
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
11
Streams access sequences of ____.
A.bytes
B.files
C.characters
D.strings
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
12
Which class is used for output of binary data?
A.Reader
B.Writer
C.OutputStream
D.InputStream
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
13
Which file storage method is in human-readable form?
A.byte
B.text
C.binary
D.object
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
14
Which of these classes access sequences of characters?
I readers
II writers
III streams
A.II and III only
B.II only
C.I only
D.I and II only
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
15
If you store information in binary form, as a sequence of bytes, you will use the ____ class(es) and their subclasses.
A.Reader and Writer
B.PrintWriter
C.Serializable
D.InputStream and OutputStream
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
16
A byte is composed of ____ bits and can denote ____ values.
A.8, 256
B.4, 256
C.8, 1024
D.2, 19
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
17
If you access and store information in binary form in files, you will use the ____ class(es).
A.Scanner and PrintWriter
B.PrintStream
C.FileInputStream and FileOutputStream
D.Reader and Writer
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
18
The ______ method returns an integer, either -1 (at the end of the file) or a byte between 0 and 255.
A.InputStream.read
B.OutputStream.write
C.Reader.length
D.Scanner.next
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
19
Readers and writers access sequences of ____.
A.bytes
B.files
C.streams
D.characters
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
20
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 and II only
B.I only
C.III only
D.I and III only
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
21
How many bytes does the read method in the FileInputStream class get from the file?
A.1
B.8
C.4
D.2
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
22
The values of the byte type range from ____ to ____.
A.-128, 127
B.0, 256
C.-128, 128
D.0, 255
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
23
What is the lowest value for a signed (negative and positive) byte?
A.-128
B.-256
C.-255
D.-127
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
24
Fill in the blank in the following code snippet to create an object for writing binary data to a disk file, named output.bin?
try (______________________________)
{
Process output
}
A.Writer out = new Writer("output.bin");
B.PrintWriter out = new PrintWriter("output.bin");
C.FileOutputStream out = new FileOutputStream("output.bin");
D.FileWriter out = new FileWriter("output.bin");
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
25
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which key should you use to encrypt picture into mfzqrob?
A.19
B.-3
C.-19
D.3
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
26
You would need a Caesar cipher with a shift of __________ to decrypt the 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.19
B.7
C.-19
D.20
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
27
Which statement is NOT correct about the OutputStream.write method?
A.The method writes an int (4 bytes) to the output stream.
B.The type of the parameter for the method is int.
C.The FileOutputStream class overrides the method to write a single byte to a file.
D.The value of the parameter must be between the values of 0 and 255.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
28
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which is the decryption of exmmv for a key = -3?
A.bujjs
B.atiir
C.cvkkt
D.happy
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
29
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which is the encryption of shadow for a key = 3?
A.adowsha
B.vkdgrz
C.vjegrz
D.ukdgry
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
30
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 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) % 256);
B.return (b + key % 26);
C.return (b + key);
D.return (b + 26 % key);
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
31
Which class has a write method that writes a single byte?
A.Stream
B.PrintWriter
C.OutputStream
D.Writer
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
32
What is the highest value for a signed (negative and positive) byte?
A.256
B.127
C.128
D.255
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
33
In ____________ file access, the file is processed starting from the beginning.
A.binary
B.random
C.parallel
D.sequential
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
34
In Java, the byte type is a(n) ____ type.
A.unsigned
B.positive
C.signed
D.negative
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
35
What is returned by the read method when a FileInputStream has reached the end of the file?
A.0
B.-1
C.-2
D.'\n'
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
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.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);
C.return (b - key % 26);
D.return (b - key) % 256);
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
37
Why does FileInputStream override the read method from its superclass InputStream?
A.In order to read binary data.
B.In order to return a char.
C.To check for end of file.
D.To read data from a file.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
38
A Caesar cipher uses a shift of each character by a key with a value between 1 and 255.An a with a shift of 3 becomes a d.A z with a shift of 3 would become a c, wrapping around the alphabet.Which is the encryption of picture for a key = -3?
A.mfzqrob
B.erutcip
C.urepict
D.ngahspc
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
39
You cannot read a ____________________ file with a text editor.
A.serial
B.binary
C.random
D.sequential
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
40
The read method of the FileInputStream class reads binary data.What type is actually returned from a call to read?
A.int
B.String
C.byte
D.char
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
41
In which of the following modes can a RandomAccessFile be opened?
I r
II rw
III w
A.I and III only
B.I only
C.I and II only
D.II only
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
42
Which code moves the file pointer to the middle of a RandomAccessFile object, file?
A.file.seek(file.getFilePointer() / 2)
B.file.seek(file.length() / 2)
C.file.seek(0L)
D.file.seek(file.length())
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
43
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 represents the offset to the beginning of the 25th record?
A.MyData.RECORD_SIZE * 2
B.MyData.RECORD_SIZE + file.getFilePointer()
C.MyData.RECORD_SIZE + 1
D.file.getFilePointer()
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
44
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 + 25
C.MyData.RECORD_SIZE++
D.MyData.RECORD_SIZE * 24
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following classes are used with data in binary form?
I FileInputStream
II FileReader
III RandomAccessFile
A.I and III only
B.I and II only
C.II and III only
D.I only
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
46
Which is NOT a method in the RandomAccessFile class?
A.seek
B.length
C.getFilePointer
D.scan
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
47
__________ access allows file access at arbitrary locations, without first reading the bytes preceding the access location.
A.Sequential
B.Serial
C.Random
D.Binary
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
48
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.file.length() / MyData.RECORD_SIZE
C.MyData.RECORD_SIZE + file.getFilePointer()
D.file.seek(0L) / MyData.RECORD_SIZE
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
49
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? 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?
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
50
A file pointer is a position in a random access file.Because files can be very large, the file pointer is of type _______.
A.int
B.double
C.long
D.byte
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
51
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? 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?
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
52
Which method in the RandomAccessFile class provides for random access?
A.goto
B.offset
C.seek
D.move
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
53
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.length() - n;
C.test.seek(n);
D.test.getFilePointer();
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
54
The readInt and writeInt methods of the RandomAccessFile class read and write integers as ____ quantities.
A.two-byte
B.four-byte
C.eight-byte
D.six-byte
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
55
When storing numbers in a file with fixed record sizes, it is easier to store them in __________ format.
A.character
B.binary
C.serializable
D.text
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
56
The readDouble and writeDouble methods of the RandomAccessFile class, process double precision floating-point numbers as ____ quantities.
A.ten-byte
B.two-byte
C.four-byte
D.eight-byte
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
57
Which statement about object streams is NOT correct?
A.Use object input streams to load the saved objects.
B.You must cast the returned result from the readObject method.
C.Any object can be saved to an object output stream.
D.Use object output streams to save all instance variables of an object automatically.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
58
What do we call the measure in bytes of the file pointer from the beginning of a RandomAccessFile?
A.size
B.seek
C.latency
D.offset
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
59
Which is not a method available in the RandomAccessFile class?
A.readDouble
B.open
C.readInt
D.close
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
60
Which method moves the file pointer in a RandomAccessFile?
A.close
B.seek
C.length
D.getFilePointer
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
61
Which of the following cannot be serialized?
I ArrayList
II String
III Integer
A.I only
B.III only
C.II and III only
D.All can be serialized
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
62
What type is returned from a call to the ObjectInputStream.readObject method when reading a String from an object stream?
A.String
B.ObjectStream
C.Object
D.char
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
63
How many methods are required to implement the Serializable interface?
A.3
B.1
C.0
D.2
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
64
Every object is assigned a serial number on the stream.What might be the result if the same object is saved twice?
A.A performance decrease.
B.Running out of serial numbers.
C.The object will have two serial numbers.
D.Only the serial number is written out the second time.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
65
Which interface allows classes to be written to an ObjectOutputStream?
A.Streaming
B.Serializable
C.Objectifiable
D.Objective
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
66
In which package are the following types found: Path, Paths, Files?
A.java.io.file
B.java.nio
C.java.nio.file
D.java.io
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
67
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
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
68
Which code reads an array of Student objects from a file named studentFile.bin? We ignore exceptions in this problem. Which code reads an array of Student objects from a file named studentFile.bin? We ignore exceptions in this problem.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
69
Fill in the blank in the following code snippet.
______ myVariable = Paths.get("filename.txt");
A.FileReader
B.File
C.Path
D.FileInputStream
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
70
Which of the following classes are related through inheritance?
I InputStream
II InputStreamReader
III ObjectInputStream
A.I, II and III
B.I and III only
C.II and III only
D.I and II only
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
71
What type of object describes the location of a file or directory?
A.Path
B.Paths
C.Files
D.Directories
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
72
If we want to write objects to a file, what type of object should be passed to the ObjectOutputStream constructor?
A.FileOutputStream
B.ObjectStream
C.ObjectInputStream
D.FileStream
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
73
Objects are saved in ___________ format in object streams.
A.integer
B.binary
C.stream
D.character
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
74
Which code stores an array studentArray of Student objects in a file named studentFile.bin? We ignore exceptions in this problem. Which code stores an array studentArray of Student objects in a file named studentFile.bin? We ignore exceptions in this problem.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
75
Which of the following is NOT a method of the Path type?
A.walk
B.getParent
C.resolve
D.getFileName
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
76
The two IO classes used for serialization are _______ and ________.
A.Reader, Writer
B.ObjectInputStream, ObjectOutputStream
C.FileReader, FileWriter
D.Scanner, PrintWriter
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
77
Objects saved to an object stream must belong to classes that ______________.
A.implement the ObjectInputStream interface
B.are RandomAccessFile objects
C.implement the Serializable interface
D.are abstract
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
78
Which expression returns a String representing the full path to the file filename.txt?
A.Paths.get("filename.txt")
B.Paths.get("filename.txt").toString()
C.Paths.get("filename.txt").toAbsolutePath()
D.Paths.get("filename.txt").toAbsolutePath().toString()
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
79
Which methods are not in the Serializable interface?
I readObject
II writeObject
III serializeObject
A.II and III only
B.I, II, and III
C.I and II only
D.I only
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
80
If you write a simple Student class, what must you do in order to write Student objects to an ObjectOutputStream?
A.Make all class variables primitive.
B.Implement Streamable.
C.Code a write method.
D.Implement Serializable.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 90 flashcards in this deck.