Deck 14: 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
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
Play
Full screen (f)
Deck 14: Files and Streams
1
When you store data in a computer file on a persistent storage device, what are you doing?
A) You are reading from the file.
B) You are using an input stream.
C) You are writing to the file.
D) You are flashing the data to memory.
A) You are reading from the file.
B) You are using an input stream.
C) You are writing to the file.
D) You are flashing the data to memory.
C
2
The terms directory and folder are used synonymously to refer to an entity that is used to organize files.
True
3
Files exist on devices such as hard disks, USB drives, reels of magnetic tape, and optical discs.What are these files considered to be?
A) temporary files
B) volatile files
C) soft files
D) permanent files
A) temporary files
B) volatile files
C) soft files
D) permanent files
D
4
Most computer users organize their files into directories, which are also known by what term?
A) folders
B) bins
C) buckets
D) drawers
A) folders
B) bins
C) buckets
D) drawers
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
How does a C# application open a file?
A) It opens a file by associating the file with a memory address.
B) It opens a file by reading the contents into RAM and storing them internally as a string.
C) It opens a file by creating an object and associating a stream of bytes with that object.
D) It opens a file by reading each line of a file into an array.
A) It opens a file by associating the file with a memory address.
B) It opens a file by reading the contents into RAM and storing them internally as a string.
C) It opens a file by creating an object and associating a stream of bytes with that object.
D) It opens a file by reading each line of a file into an array.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
The File class is contained in the System.IOFile namespace.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
When a C# application is done using a file, what should it do with the file?
A) It should delete the file.
B) It should return the file to RAM.
C) It should truncate the file.
D) It should close the file.
A) It should delete the file.
B) It should return the file to RAM.
C) It should truncate the file.
D) It should close the file.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
When you copy data from a file on a storage device into RAM, what are you doing?
A) You are writing to the file.
B) You are reading from the file.
C) You are copying to the file.
D) You are flashing the data to memory.
A) You are writing to the file.
B) You are reading from the file.
C) You are copying to the file.
D) You are flashing the data to memory.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
Permanent storage that does not lose contents when a computer loses power is known as what type of storage?
A) volatile
B) temporal
C) nonvolatile
D) soft storage
A) volatile
B) temporal
C) nonvolatile
D) soft storage
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
A CSV file contains values separated by semicolon delimiters.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
A data file is what type of file when each record is read in order of its position in the file?
A) sequential access file
B) random access file
C) dynamic read file
D) temporary buffer file
A) sequential access file
B) random access file
C) dynamic read file
D) temporary buffer file
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
What is a collection of fields that contain data about an entity?
A) a file
B) a character
C) a record
D) a bit
A) a file
B) a character
C) a record
D) a bit
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
When you write a program and save it to a disk, you are using temporary storage.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
What class contains methods that allow you to access information about files?
A) Cabinet
B) File
C) Directory
D) Folder
A) Cabinet
B) File
C) Directory
D) Folder
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
Files are used to store data on nonvolatile memory.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
What class can be used to provide information on directories or folders?
A) Directory
B) File
C) Cabinet
D) Folder
A) Directory
B) File
C) Cabinet
D) Folder
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
Due to the fact that data can be erased from files, what term do programmers generally prefer over permanent storage?
A) volatile storage
B) temporary storage
C) transit storage
D) persistent storage
A) volatile storage
B) temporary storage
C) transit storage
D) persistent storage
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
What format is used by files that store music or images?
A) data
B) binary
C) text
D) information
A) data
B) binary
C) text
D) information
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
When you write a C# program that stores a value in a variable, you are using temporary storage; the value you store is lost when the program ends or the computer loses power.What is the name for this kind of storage?
A) volatile
B) nonvolatile
C) permanent
D) hard
A) volatile
B) nonvolatile
C) permanent
D) hard
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
What term describes any one of the letters, numbers, or other special symbols (such as punctuation marks) that comprise data.
A) field
B) record
C) delimiter
D) character
A) field
B) record
C) delimiter
D) character
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
When you perform an input operation in an application, the bytes flowing into your program from an input device typically are pictured by programmers as what?
A) A directory filling and emptying.
B) A stream of information.
C) A bucket filling with water.
D) A chunk of information.
A) A directory filling and emptying.
B) A stream of information.
C) A bucket filling with water.
D) A chunk of information.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
Approximately how many bytes are in a gigabyte?
A) a thousand bytes
B) a million bytes
C) a billion bytes
D) a trillion bytes
A) a thousand bytes
B) a million bytes
C) a billion bytes
D) a trillion bytes
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
What file mode is used to open an existing file, and empty the file once opened so that the file is zero bytes in size?
A) Append
B) Empty
C) Truncate
D) Destroy
A) Append
B) Empty
C) Truncate
D) Destroy
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
What Filestream property indicates whether the Filestream supports reading?
A) ReadAccess
B) CanRead
C) CanSeek
D) CanWrite
A) ReadAccess
B) CanRead
C) CanSeek
D) CanWrite
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
Sometimes it is necessary to process a sequential text file multiple times from the beginning during a program's execution.After the file is processed the first time, the file pointer is at the end of the file.How can you reread the file at this point?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
The FileStream class has 15 overloaded constructors.What can you tell about the FileStream object named myFile, given the constructor below?
FileStream myFile =
new FileStream("SomeText.txt", FileMode.Create,
FileAccess.Write);
FileStream myFile =
new FileStream("SomeText.txt", FileMode.Create,
FileAccess.Write);
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
If you attempt to open a file with the Open file mode, what happens if the file does not exist?
A) The file is created and then opened for use.
B) The program returns a prompt to the user asking if the file should be created.
C) The program will return a null object, and all data written to the file will be discarded.
D) The program throws a System.IO.FileNotFoundException error.
A) The file is created and then opened for use.
B) The program returns a prompt to the user asking if the file should be created.
C) The program will return a null object, and all data written to the file will be discarded.
D) The program throws a System.IO.FileNotFoundException error.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
What must be done in order to convert streams of bytes back into objects?
A) deserialization
B) serialization
C) normalization
D) denormalization
A) deserialization
B) serialization
C) normalization
D) denormalization
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
What method is a member of the String class and takes a character delimiter parameter and separates a string into substrings at each occurrence of the delimiter?
A) Separate()
B) Split()
C) Delimit()
D) Substring()
A) Separate()
B) Split()
C) Delimit()
D) Substring()
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
Describe some of the methods of the Directory class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
What is a character?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
Hardcoding numbers (unnamed, literal constants) in code without explanation is a bad programming practice.What are these hardcoded numbers known as?
A) constant issues
B) token numbers
C) magic numbers
D) character sets
A) constant issues
B) token numbers
C) magic numbers
D) character sets
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
When you produce screen output and accept keyboard input, you use the Console class, which provides access to which three standard streams?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
What is the process of converting objects into streams of bytes known as?
A) deserialization
B) normalization
C) streaming
D) serialization
A) deserialization
B) normalization
C) streaming
D) serialization
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
When a file is open in C#, what holds the byte number of the next byte to be read?
A) the file token
B) the file position pointer
C) the magic number
D) the record token
A) the file token
B) the file position pointer
C) the magic number
D) the record token
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
What is a record?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
What are the disadvantages to writing data to a text file using tokens and delimiters as opposed to writing an entire object to a file at once?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
Write a program that prompts a user for a filename and tests the file's existence.If the file exists, display the file creation time.If it does not exist, display a message.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
How can you create a class whose objects can be written to and read from data files? Show an example.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
A program that reads from a sequential access data file creates a FileStream object, and then the FileStream object is passed to a StreamReader object's constructor.Once this has been done, the ReadLine() method can be used to retrieve one line at a time from the data file.Show the sequence of instructions that would create the FileStream and StreamReader needed to access a data file, and then read one line from the file.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck