Deck 18: Files and Streams
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/53
Play
Full screen (f)
Deck 18: Files and Streams
1
The standard output stream object enables a program to output data to the
screen.
screen.
True
2
Console.In,Console.Out and Console.Error are used to take data in,to display data and to show error messages,respectively.
True
3
Data stored in a file is considered:
A)temporary data
B)persistent data
C)recurring data
D)there is no need to store data in files
A)temporary data
B)persistent data
C)recurring data
D)there is no need to store data in files
B
4
The Console.Error property returns:
A)a standard error stream object
B)a new error
C)an object of type error
D)None of the above
A)a standard error stream object
B)a new error
C)an object of type error
D)None of the above
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
5
Saving data to a file retains that data after the program terminates.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
6
Files can be stored in:
A)hard drives
B)optical disks
C)flash drives
D)All of the above
A)hard drives
B)optical disks
C)flash drives
D)All of the above
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
7
Classes StreamIn and StreamOut are used to read from text files and output to text files.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
8
Characters in Visual Basic are Unicode characters,each represented by one byte.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
9
The smallest data item in a computer is the _________.
A)bit
B)byte
C)kilobyte
D)None of the above.
A)bit
B)byte
C)kilobyte
D)None of the above.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
10
One byte is composed of:
A)2 bits
B)4 bits
C)8 bits
D)10 bits
A)2 bits
B)4 bits
C)8 bits
D)10 bits
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
11
A record is a group of fields and a file is a group of records.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
12
_______________ are used for long-term retention of large amounts of data.
A)Arrays
B)Buffers
C)Files
D)Data structures.
A)Arrays
B)Buffers
C)Files
D)Data structures.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
13
Directory method GetDirectories returns _______.
A)a string with all the names of sibling directories
B)an array of strings with all the names of sibling directories
C)a string with all the names of subdirectories
D)an array of strings with all the names of subdirectories
A)a string with all the names of sibling directories
B)an array of strings with all the names of sibling directories
C)a string with all the names of subdirectories
D)an array of strings with all the names of subdirectories
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
14
No matter how complicated a program is or looks it can all be broken down into a series of 0's and 1's.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
15
In a data hierarchy,data items become larger and more complex in structure as we progress from bits,to characters,to fields and up to large data structures.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
16
When a file is opened,a stream object is created and associated with the file.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
17
Data stored in arrays is permanent data.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
18
Visual Basic views every file simply as a sequential stream of bytes.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
19
To distinguish records,there has to be at least one field that is unique for each instance;this is called the record key.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
20
In a ____________ file,records are typically stored in order by a record-key field.
A)chronological
B)non-sequential
C)sequential
D)record-key
A)chronological
B)non-sequential
C)sequential
D)record-key
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following methods of FileStream will reset the file-position pointer back to the beginning of the file?
A)Reset
B)Origin
C)Seek
D)Beginning
A)Reset
B)Origin
C)Seek
D)Beginning
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
22
An OpenFileDialog allows a user to select a file to open.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
23
Visual Basic provides the class _______ for manipulating files.
A)Folder
B)FileUtil
C)File
D)FileManip
A)Folder
B)FileUtil
C)File
D)FileManip
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
24
The enumeration FileAccess is used to ________.
A)control future users' access to a file
B)control program access to a file
C)control the amount of updating that can be done on a file at once
D)FileAccess is a method,not an enumeration.
A)control future users' access to a file
B)control program access to a file
C)control the amount of updating that can be done on a file at once
D)FileAccess is a method,not an enumeration.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
25
Records in a sequential access file are always sorted by a record key
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
26
To access a file,you must instantiate an object of type File.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
27
What kind of exception is thrown if there's a problem opening or creating a StreamWriter?
A)Exception
B)StreamException
C)OpenAndCreatingException
D)IOException
A)Exception
B)StreamException
C)OpenAndCreatingException
D)IOException
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
28
Class File can only create new files.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
29
Which method creates a new file and returns a stream to process that file?
A)CreateFile method of class File
B)NewFile method of class File
C)Create method of class File
D)New method of class File
A)CreateFile method of class File
B)NewFile method of class File
C)Create method of class File
D)New method of class File
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
30
Every file automatically closes itself when it's no longer needed.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
31
You can use the FileAccess enumeration to control access to
file when the file is opened.
file when the file is opened.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
32
A FileStream object can throw a(n)________ if an attempt is made to open a file that does not exist.
A)NoFileException
B)FileNotFoundException
C)OpenErrorException
D)FileStreamException.
A)NoFileException
B)FileNotFoundException
C)OpenErrorException
D)FileStreamException.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
33
A _____________ contains the byte number of the next byte in a file to be read or written to a file.
A)data locator
B)file counter
C)file-position pointer
D)byte-number counter.
A)data locator
B)file counter
C)file-position pointer
D)byte-number counter.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
34
The classes dealing with files and directories are located in the System.IO namespace.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
35
Method GetFiles of Directory can be used to obtain a list of all the files in a given directory.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
36
What is the exception thrown when an error occurs during serialization or deserialization?
A)SerialException
B)DeserialException
C)SerializationException
D)DeserializationException
E)c and d,respectively
A)SerialException
B)DeserialException
C)SerializationException
D)DeserializationException
E)c and d,respectively
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
37
Class Directory can be used to change directories.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
38
When a FileStream object is opened,the file-position pointer is _________.
A)set to Nothing
B)set to 0
C)needs to be explicitly created
D)set to the end of the file
A)set to Nothing
B)set to 0
C)needs to be explicitly created
D)set to the end of the file
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
39
A serialized object is an object that includes ________.
A)a sequence of bytes about the object's data
B)information about the object's type
C)information about the types of data stored in the object
D)All of the above
A)a sequence of bytes about the object's data
B)information about the object's type
C)information about the types of data stored in the object
D)All of the above
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
40
A StreamReader object must be created in order to retrieve data from a text file.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
41
BinaryFormatter allows for only reading objects.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
42
Which of the following attributes is needed to indicate to the CLR that objects of the class can be serialized?
A)
B)
C)
D)both a and b
A)
B)
C)
D)both a and b
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
43
For variables of reference types,you must check the class declaration to ensure that the type is serializable.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
44
By default,array objects are not serializable.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
45
BinaryFormatter's Serialize and Deserialize methods are both parameterless.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
46
Another way that a class could indicate to the CLR that objects of the class can be serialized is through implementing the ________ interface.
A)Serializable
B)ISerializable
C)Serial
D)ISerial
A)Serializable
B)ISerializable
C)Serial
D)ISerial
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
47
All primitive-type variables and strings are serializable.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
48
Method ________ of class BinaryFormatter reads a serialized object from a stream and reforms the object in memory.
A)Deserial
B)Deserialize
C)Deserializable
D)DSerial
A)Deserial
B)Deserialize
C)Deserializable
D)DSerial
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
49
In a class that's marked with the <Serializable()> attribute or that implements interface ISerializable,not every instance variable of the class needs to be serializable.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
50
The name of the file to open is specified as the first argument to the FileStream constructor.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
51
Deserialize returns a reference of type:
A)Object which must be cast to the appropriate type to manipulate the object
B)the type that the object was originally
C)Deserialized which must be cast to the appropriate type to manipulate the object
D)None of the above
A)Object which must be cast to the appropriate type to manipulate the object
B)the type that the object was originally
C)Deserialized which must be cast to the appropriate type to manipulate the object
D)None of the above
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
52
An array is always serializable.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
53
BinaryFormatters can be used to serialize and deserialize objects coming in and going out of a stream.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck