Writing Data to a Sequential Access File - Visual Basic Questions and Answers

1.

Reading data from a file is referred to as ________________

   A.) Reading a file
   B.) Executing a file
   C.) Appending a file
   D.) Writing a file

Answer: Option 'A'

Reading a file

In addition to getting data from the keyboard and sending data to the computer screen, an application also can get data from and send data to a file on a disk. Getting data from a f le is referred to as “reading the file,” and sending data to a file is referred to as “writing to the file.”

DigitalOcean Referral Badge

2.

Writing data to a file is referred to as ______________

   A.) Reading a file
   B.) Writing a file
   C.) Executing a file
   D.) Writing a file

Answer: Option 'B'

Writing a file

In addition to getting data from the keyboard and sending data to the computer screen, an application also can get data from and send data to a file on a disk. Getting data from a f le is referred to as “reading the file,” and sending data to a file is referred to as “writing to the file.”

DigitalOcean Referral Badge

3.

The file to which data is write is referred to as _______________

   A.) Input file
   B.) Output file
   C.) Random access file
   D.) Sequential file

Answer: Option 'B'

In addition to getting data from the keyboard and sending data to the computer screen, an application also can get data from and send data to a file on a disk. Getting data from a file is referred to as “reading the file,” and sending data to a file is referred to as “writing to the file.” Files to which data is written are called output files, because the files store the output produced by an application.

DigitalOcean Referral Badge

4.

Files that are read by computer are called as _________________

   A.) Input file
   B.) Output file
   C.) Random access file
   D.) Sequential file

Answer: Option 'A'

Files to which data is written are called output files, because the files store the output produced by an application. Files that are read by the computer are called input files, because an application uses the data in these files as input. Most input and output files are composed of lines of text that are both read and written sequentially.

DigitalOcean Referral Badge

5.

Files that read and write in consecutive order are known as _________________

   A.) Input files
   B.) Output files
   C.) Sequential access file
   D.) Random access file

Answer: Option 'C'

Sequential access file

Most input and output files are composed of lines of text that are both read and written sequentially. In other words, they are read and written in consecutive order, one line at a time, beginning with the first line in the file and ending with the last line in the file. Such files are referred to as sequential access files, because of the manner in which the lines of text are accessed.

DigitalOcean Referral Badge

6.

Files that contain lines of text are known as _______________

   A.) Binary files
   B.) Text files
   C.) Character files
   D.) Character files

Answer: Option 'B'

Text files
Most input and output files are composed of lines of text that are both read and written sequentially. In other words, they are read and written in consecutive order, one line at a time, beginning with the first line in the file and ending with the last line in the file. Such files are referred to as sequential access files, because of the manner in which the lines of text are accessed. They also are called text files, because they are composed of lines of text. Examples of text stored in sequential access files include an employee list, a memo, or a sales report.

DigitalOcean Referral Badge

7.

Programmers refer to the sequence of character as ___________________

   A.) Stream of tokens
   B.) Stream of characters
   C.) Stream of bytes
   D.) Stream of bits

Answer: Option 'B'

Stream of characters

An item of data—such as the string “Harriet”—is viewed differently by a human being and a computer. To a human being, the string represents a person’s name; to a computer, it is merely a sequence of characters. Programmers refer to a sequence of characters as a stream of characters.

DigitalOcean Referral Badge

8.

In Visual Basic, you use _________________ to write a stream of characters.

   A.) StreamWriter object
   B.) StreamWriter object
   C.) StreamWriter object
   D.) StreamWriter object

Answer: Option 'A'

Programmers refer to a sequence of characters as a stream of characters. In Visual Basic, you use a StreamWriter object to write a stream of characters to a sequential access file. Before you create the StreamWriter object, you first declare a variable to store the object in the computer’s internal memory. The syntax is as follows:

DigitalOcean Referral Badge

9.

____________________ is used to open a sequential access file for output.

   A.) CreateText method
   B.) OpenText method
   C.) WriteText method
   D.) AppendText method

Answer: Option 'A'

CreateText method

Creating a StreamWriter object involves opening a sequential access file using one of two methods: CreateText or AppendText. You use the CreateText method to open a sequential access file for output. When you open a file for output, the computer creates a new, empty file to which data can be written. If the file already exists, the computer erases the contents of the file before writing any data to it.

DigitalOcean Referral Badge

10.

_____________ is used to open the sequential file access for append.

   A.) CreateText method
   B.) CreateText method
   C.) OpenText method
   D.) WriteText method

Answer: Option 'B'

You use the AppendText method to open a sequential access file for append. When a file is opened for append, new data is written after any existing data in the file. If the file does not exist, the computer creates the file for you. In addition to opening the file, both methods automatically create a StreamWriter object to represent the file in the application. You assign the StreamWriter object to a StreamWriter variable, which you use to refer to the file in code.

DigitalOcean Referral Badge

Writing Data to a Sequential Access File - Visual Basic Questions and Answers Download Pdf

Recent Posts