Chapter 22 You can use the Exists method to avoid the run time

subject Type Homework Help
subject Pages 4
subject Words 713
subject Authors Diane Zak

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Chapter 22: I’m Saving for the Future (Sequential Access Files)
TRUE/FALSE
1. In addition to getting data from the keyboard and sending data to the computer screen, an application
can also get data from and send data to a file on a disk.
2. Most input and output files are composed of lines of text that are both read and written sequentially.
3. An item of data—such as the string “Taylor”—is viewed similarly by a human being and a computer.
4. Before you create a StreamWriter object, you first declare a variable to store the object in the
computer’s internal memory.
5. When you open a file for output, if the file already exists, the computer erases the contents of the file
before writing any data to it.
6. The “doc” filename extension is commonly used when naming sequential access files.
7. When you are writing data to a file, in most cases you will use the Write method.
8. You can use a text box’s Focus method to send the focus to the text box during run time.
9. After creating the StreamReader object, you declare a variable to store the object in the computer’s
internal memory.
10. You can use the Exists method to avoid the run time error that occurs when the computer cannot locate
the file you want opened for input.
11. The ReadLine method returns a string that contains the sequence of characters in the current line,
including the newline character at the end of the line.
page-pf2
12. In most cases, you assign the string returned by the ReadLine method to a String variable.
13. The ReadLine method requires you to provide the file’s name.
14. In most cases, an application will need to read each line of text contained in a sequential access file,
one line at a time.
15. The Peek method determines whether a file contains another character to read.
MULTIPLE CHOICE
1. Files to which data is written are called ____ files.
a.
input
c.
writeOnly
b.
output
d.
readOnly
2. Files that are read by the computer are called ____ files.
a.
output
c.
writeOnly
b.
readOnly
d.
input
3. Most input and output files are referred to as ____ files.
a.
sequential access
c.
any access
b.
random access
d.
serial access
4. Programmers refer to a sequence of characters as a(n) ____.
a.
array stream
c.
flow
b.
bytestream
d.
stream of characters
5. In Visual Basic, you use a ____ object to write a stream of characters to a sequential access file.
a.
StreamReader
c.
StreamWriter
b.
StreamWriteObject
d.
StreamReadWriteObject
6. The syntax for declaring a streamwriter variable is ____.
a.
[Dim | Private] streamWriterVariableName As IO.StreamWriter
b.
{Dim | Private} streamWriterVariableName As IO.StreamWriter
c.
{Dim | Private} streamWriterVariableName As
page-pf3
IO.StreamWriteObject
d.
Private streamWriterVariableName As IO.StreamWriter
7. You use the ____ method to create a new, empty sequential access file to which data can be written.
a.
OpenText
c.
CreateText
b.
AppendText
d.
NewText
8. If the file to be opened exists, the ____ method writes new data after any existing data in the file.
a.
InsertText
c.
CreateText
b.
AppendText
d.
AddText
9. The syntax to close a sequential access file associated with a StreamWriter object is ____.
a.
streamWriterVariableName.Close()
b.
streamWriterVariableName.FileClose()
c.
streamWriterVariableName.CloseFile()
d.
Close.streamWriterVariableName(data)
10. After declaring a StreamReader variable, you can use the ____ method to open a sequential access file
for input, which automatically creates a StreamReader object.
a.
ReadText
c.
GetText
b.
InputText
d.
OpenText
11. The ____ method returns the Boolean value True if the file exists; otherwise, it returns the Boolean
value False.
a.
IsThere
c.
DoesExist
b.
CanFind
d.
Exists
12. The syntax for determining whether a sequential access file exists is ____.
a.
IO.Exists(fileName)
c.
IO.File.Exists(fileName)
b.
IO.(fileName).Exists()
d.
IO.File(fileName).Exists
13. The ____ method can be used to read a file’s contents, one line at a time.
a.
Read
c.
ReadInputLine
b.
ReadLine
d.
ReadInput
14. A ____ is defined as a sequence (stream) of characters followed by the newline character.
a.
line
c.
column
b.
row
d.
string
page-pf4
15. The syntax of the Peek method is ____.
a.
streamReaderVariableName.Peekaboo
b.
Peek.streamReaderVariableName
c.
streamReaderVariableName.Peek
d.
Peek(streamReaderVariableName)

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.