Deck 19: Streams and Binary Inputoutput

ملء الشاشة (f)
exit full mode
سؤال
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");
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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
سؤال
The ____ class is used when writing text files.

A) PrintWriter
B) InputStream
C) JFileChooser
D) Serializable
سؤال
Which class is used for input of binary data?

A) Reader
B) Writer
C) InputStream
D) OutputStream
سؤال
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");
سؤال
Which class is used for input of text data from a file?

A) RandomAccessFile
B) FileWriter
C) FileInputStream
D) Scanner
سؤال
In Java, the simplest mechanism for reading text is to use the ____ class.

A) ReadWrite
B) Scanner
C) PrintWriter
D) Serializable
سؤال
Which class is used for input of text data?

A) Reader
B) Writer
C) InputStream
D) OutputStream
سؤال
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
سؤال
Readers and writers access sequences of ____.

A) bytes
B) characters
C) files
D) streams
سؤال
Which file storage method is in human-readable form?

A) binary
B) object
C) text
D) byte
سؤال
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"));
سؤال
When constructing a Scanner from a File object, the Scanner automatically constructs a ___________.

A) InputStream
B) FileInputStream
C) FileReader
D) PrintWriter
سؤال
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
سؤال
In text format, data items are represented in human-readable form, as a sequence of ____________________.

A) integers
B) bytes
C) characters
D) strings
سؤال
To read text data from a disk file, you should create a(n) ____________________ object.

A) Scanner
B) PrintWriter
C) InputStream
D) OutputStream
سؤال
Streams access sequences of ____.

A) characters
B) files
C) strings
D) bytes
سؤال
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);
سؤال
Which file storage method stores data in bytes?

A) binary
B) object
C) text
D) byte
سؤال
A byte is composed of ____ bits and can denote ____ values.

A) 2, 19
B) 4, 256
C) 8, 256
D) 8, 1024
سؤال
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.
سؤال
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
سؤال
What is the highest value for a signed (negative and positive) byte?

A) 127
B) 128
C) 255
D) 256
سؤال
How many bytes does the read method in the FileInputStream class actually get from the file?

A) 1
B) 2
C) 4
D) 8
سؤال
How many bytes does the read method in the InputStream class get from the file?

A) 1
B) 2
C) 4
D) 8
سؤال
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
سؤال
You cannot read a(n) ____________________ file with a text editor.

A) random
B) serial
C) sequential
D) binary
سؤال
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
سؤال
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
سؤال
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

A) return (b + key);
B) { ________ }
B) return (b - key % 26);
C) return (b - key) % 256);
D) return (b - key);
سؤال
What is the lowest value for a signed (negative and positive) byte?

A) -127
B) -128
C) -255
D) -256
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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

A) return (b + key);
B) { __________ }
B) return (b + key % 26);
C) return (b + key) % 256);
D) return (b + 26 % key);
سؤال
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
سؤال
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
سؤال
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.
سؤال
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
سؤال
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
سؤال
Which is not a method available in the RandomAccessFile class?

A) open
B) readInt
C) readDouble
D) close
سؤال
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
سؤال
In Java, the byte type is a(n) ____ type.

A) positive
B) signed
C) negative
D) unsigned
سؤال
Which method in the RandomAccessFile class provides for random access?

A) move
B) seek
C) goto
D) offset
سؤال
In Java, you use a(n) ____________ object to access a file and move its file pointer.

A) Stream
B) Serializable
C) SequentialAccessFile
D) RandomAccessFile
سؤال
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
سؤال
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
سؤال
The values of the byte type range from ____ to ____.

A) 0, 255
B) 0, 256
C) -128, 128
D) -128, 127
سؤال
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()
سؤال
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.
سؤال
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);
سؤال
Which is not a method in the RandomAccessFile class?

A) getFilePointer
B) seek
C) scan
D) length
سؤال
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
سؤال
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
سؤال
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
سؤال
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);
سؤال
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);
سؤال
In ____________ file access, the file is processed starting from the beginning.

A) random
B) serial
C) sequential
D) binary
سؤال
__________ access allows file access at arbitrary locations, without first reading the bytes preceding the access location.

A) Random
B) Serial
C) Sequential
D) Binary
سؤال
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.
سؤال
Objects are saved in ___________ format in object streams.

A) binary
B) character
C) stream
D) integer
سؤال
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
سؤال
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
سؤال
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;
سؤال
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
سؤال
Which interface allows classes to be written to an ObjectOutputStream?

A) Objective
B) Streaming
C) Serializable
D) Objectifiable
سؤال
How many methods are required to implement the Serializable interface?

A) 3
B) 2
C) 1
D) 0
سؤال
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
سؤال
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
سؤال
Which method moves the file pointer in a RandomAccessFile?

A) seek
B) length
C) getFilePointer
D) close
سؤال
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)
سؤال
Which of the following cannot be serialized?
I ArrayList
II String
III Integer

A) I
B) II and III
C) III
D) All can be serialized
سؤال
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
سؤال
Use a ____ object to access a file and move a file pointer.

A) Random
B) RandomAccess
C) RandomAccessFile
D) System.in
سؤال
The two IO classes used for serialization are _______ and ________.

A) Reader, Writer
B) ObjectInputStream, ObjectOutputStream
C) Scanner, PrintWriter
D) FileReader, FileWriter
سؤال
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.
سؤال
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
سؤال
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
سؤال
In which package are most classes for file processing found?

A) java.file
B) java.inputoutput
C) java.io
D) java.stream
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/82
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 19: Streams and Binary Inputoutput
1
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");
A
2
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
B
3
The ____ class is used when writing text files.

A) PrintWriter
B) InputStream
C) JFileChooser
D) Serializable
A
4
Which class is used for input of binary data?

A) Reader
B) Writer
C) InputStream
D) OutputStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
5
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");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which class is used for input of text data from a file?

A) RandomAccessFile
B) FileWriter
C) FileInputStream
D) Scanner
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
7
In Java, the simplest mechanism for reading text is to use the ____ class.

A) ReadWrite
B) Scanner
C) PrintWriter
D) Serializable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which class is used for input of text data?

A) Reader
B) Writer
C) InputStream
D) OutputStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
9
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
10
Readers and writers access sequences of ____.

A) bytes
B) characters
C) files
D) streams
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which file storage method is in human-readable form?

A) binary
B) object
C) text
D) byte
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
12
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"));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
13
When constructing a Scanner from a File object, the Scanner automatically constructs a ___________.

A) InputStream
B) FileInputStream
C) FileReader
D) PrintWriter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
14
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
15
In text format, data items are represented in human-readable form, as a sequence of ____________________.

A) integers
B) bytes
C) characters
D) strings
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
16
To read text data from a disk file, you should create a(n) ____________________ object.

A) Scanner
B) PrintWriter
C) InputStream
D) OutputStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
17
Streams access sequences of ____.

A) characters
B) files
C) strings
D) bytes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
18
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which file storage method stores data in bytes?

A) binary
B) object
C) text
D) byte
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
20
A byte is composed of ____ bits and can denote ____ values.

A) 2, 19
B) 4, 256
C) 8, 256
D) 8, 1024
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
21
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
22
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
23
What is the highest value for a signed (negative and positive) byte?

A) 127
B) 128
C) 255
D) 256
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
24
How many bytes does the read method in the FileInputStream class actually get from the file?

A) 1
B) 2
C) 4
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
25
How many bytes does the read method in the InputStream class get from the file?

A) 1
B) 2
C) 4
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
26
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
27
You cannot read a(n) ____________________ file with a text editor.

A) random
B) serial
C) sequential
D) binary
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
28
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
29
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
30
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

A) return (b + key);
B) { ________ }
B) return (b - key % 26);
C) return (b - key) % 256);
D) return (b - key);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
31
What is the lowest value for a signed (negative and positive) byte?

A) -127
B) -128
C) -255
D) -256
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
32
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
34
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
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 encrypt method below, select the correct body. Assume the key shift property is accessible to the method.
Public int encrypt(int

A) return (b + key);
B) { __________ }
B) return (b + key % 26);
C) return (b + key) % 256);
D) return (b + 26 % key);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
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 is the encryption of picture for a key = -3?

A) erutcip
B) ngahspc
C) mfzqrob
D) urepict
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
38
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
39
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
40
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
41
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
42
Which is not a method available in the RandomAccessFile class?

A) open
B) readInt
C) readDouble
D) close
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
43
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
44
In Java, the byte type is a(n) ____ type.

A) positive
B) signed
C) negative
D) unsigned
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
45
Which method in the RandomAccessFile class provides for random access?

A) move
B) seek
C) goto
D) offset
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
46
In Java, you use a(n) ____________ object to access a file and move its file pointer.

A) Stream
B) Serializable
C) SequentialAccessFile
D) RandomAccessFile
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
47
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
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) MyData.RECORD_SIZE + file.getFilePointer()
C) file.seek(0L) / MyData.RECORD_SIZE
D) file.length() / MyData.RECORD_SIZE
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
49
The values of the byte type range from ____ to ____.

A) 0, 255
B) 0, 256
C) -128, 128
D) -128, 127
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
50
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()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
51
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
52
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
53
Which is not a method in the RandomAccessFile class?

A) getFilePointer
B) seek
C) scan
D) length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
54
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
55
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
56
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
57
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
58
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
59
In ____________ file access, the file is processed starting from the beginning.

A) random
B) serial
C) sequential
D) binary
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
60
__________ access allows file access at arbitrary locations, without first reading the bytes preceding the access location.

A) Random
B) Serial
C) Sequential
D) Binary
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
61
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
62
Objects are saved in ___________ format in object streams.

A) binary
B) character
C) stream
D) integer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
63
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
64
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
65
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;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
67
Which interface allows classes to be written to an ObjectOutputStream?

A) Objective
B) Streaming
C) Serializable
D) Objectifiable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
68
How many methods are required to implement the Serializable interface?

A) 3
B) 2
C) 1
D) 0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
69
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
70
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
71
Which method moves the file pointer in a RandomAccessFile?

A) seek
B) length
C) getFilePointer
D) close
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
72
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
73
Which of the following cannot be serialized?
I ArrayList
II String
III Integer

A) I
B) II and III
C) III
D) All can be serialized
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
74
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
75
Use a ____ object to access a file and move a file pointer.

A) Random
B) RandomAccess
C) RandomAccessFile
D) System.in
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
76
The two IO classes used for serialization are _______ and ________.

A) Reader, Writer
B) ObjectInputStream, ObjectOutputStream
C) Scanner, PrintWriter
D) FileReader, FileWriter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
77
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
78
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
79
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
80
In which package are most classes for file processing found?

A) java.file
B) java.inputoutput
C) java.io
D) java.stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 82 في هذه المجموعة.