Question: Examine the following file processing program. import java.io.*; import java.util.Scanner; public class FileProcessing { public static void main(String args []) throws IOException { FileOutputStream outFile

Examine the following file processing program.

import java.io.*;

import java.util.Scanner;

public class FileProcessing

{

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

{

FileOutputStream outFile = null;

PrintWriter pWriter;

try

{

File inFile = new File("input.txt");

outFile = new FileOutputStream("output.txt");

pWriter = new PrintWriter(outFile);

int salary = 0;

Scanner sc = new Scanner (inFile);

while (sc.hasNextLine())

{

String line = sc.nextLine();

salary = Integer.parseInt(line) + 100;

pWriter.println(salary);

System.out.println(salary);

}

sc.close();

pWriter.close();

}

finally

{

if (outFile != null) {

outFile.close();

}

}

}

}

Contents of input.txt file: 1500

2200

7230

6500

1275

Concerning the aforementioned program code, select the correct answer.

(1) The pWriter object is associated with the file named input.txt .

(a) True (b) False

(2) The outFile file object uses the output.txt file in the APPEND mode.

(a) True (b) False

(3) When the above program is executed, the contents of the output.txt file will be the following.

1600

2300

7330

6600

1375

(a) True (b) False

(4) The outFile object is associated with the FileInputStream class.

(a) True (b) False

(5) The println() method is used by the PrintWriter object.

(a) True (b) False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!