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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started