Question: What happens when you supply the same name for the input and output fiels to the Total program? A. The program reads all the input

What happens when you supply the same name for the input and output fiels to the Total program?

A. The program reads all the input from the file and then writes the formatted values and the total to the file

B. An exception is thrown in the PrintWriter constructor

C. An exception is thrown in the call in.nextDouble()

D. The while loop is never entered.

2. What happens when you supply the name of a nonexisten input file to the total program?

A. The program writes an empty output file and exits normally

B. The program writes "Total: 0.00" to the output and exits normally.

C. The statement File inputFile = new File (inputFileName); throws an exception

D. The statement Scanner in = new Scanner(inputFile); throws an exception

3. Select the output generated by the code segment below, assuming that data is a Scanner object used to read the following text: A cup of Java.

data.useDelimiter("");

int count = 0;

while (data.hasNext())

{

char input = data.next().charAt(0);

if (!Character.isLetter()) {count++;}

}

System.out.println(count);

A. 3

B. 4

C.10

D. 14

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!