Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Select the correct answer to the given problem. (1) The following pseudocode represents the procedure for reading from a sequential file. open a stream while

Select the correct answer to the given problem.

(1) The following pseudocode represents the procedure for reading from a sequential file.

open a stream

while more information

read information

close the stream

(a) True (b) False

(2) The try - catch block is designed to enable the programmer to detect and respond to exception errors.

(a) True (b) False

(3) A sequential file can be sorted by placing its data into an array, sorting the array, and then writing the ordered data into a file.

(a) True (b) False

(4) A control break is a temporary break from the flow of the logic of a program.

(a) True (b) False

(5) Opening a file for output means that __________ .

(a) data may be stored onto the disk.

(b) data may be read from the disk.

(c) anything that appears as output on the screen is written to the disk.

(d) data may be read from and stored onto the disk.

(6) When a file is opened in the append mode, data written to the file replaces the data already there.

(a) True (b) False

(7) Which of the following statements is used when you want to add data to the end of an existing sequential file?

(a) FileWriter in = new FileWriter(outputFile);

(b) FileReader in = new FileWriter(outputFile, true);

(c) FileReader out = new FileWriter(outputFile);

(d) FileWriter out = new FileWriter(outputFile, true);

(8) When an existing file is opened for output, and not append, new data values are added at the end of the existing file.

(a) True (b) False

(9) If a sequential file is opened for input, then this allows data to be placed into the file by the Java application.

(a) True (b) False

(10) Which of the terms in the following line of code are named variables that could be replaced as long as all other references were also updated?

FileReader in = new FileReader(inFile);

(a) inFile (b) in (c) new (d) File (e) FileReader

Considering the following class file, answer each of the questions given below.

import java.io.*; import java.io.FileReader;

import java.io.FileWriter;

public class ReadWrite {

public static void main(String[] args) throws IOException {

File inputFile = new File("inData.txt");

File outputFile = new File("outData.txt");

FileReader in = new FileReader(inputFile);

FileWriter out = new FileWriter(outputFile, true);

int c;

while ((c = in.read()) != -1)

out.write(c);

in.close();

out.close();

}

}

(11) in is a FileWriter object. (a) True (b) False

(12) out is a FileReader object. (a) True (b) False

(13) inputFile is a File object associated with outData.txt . (a) True (b) False

(14) outputFile is a File object linked with inData.txt . (a) True (b) False

(15) out.close() is outside the block of the while loop. (a) True (b) False

(16) in.close() is inside the block of the while loop. (a) True (b) False

(17) The while loop is used to both read from and write to the file. (a) True (b) False

(18) (c = in.read()) != -1 is true when data can still be read. (a) True (b) False

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions