Exam 7: Inputoutput and Exception Handling

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Your program will read in an existing text file. You want the program to terminate if the file does not exist. Which of the following indicates the correct code for the main method header?

(Multiple Choice)
4.9/5
(32)

Insert the missing code in the following code fragment. This fragment is intended to read all words from a text file. File inputFile = new File("dataIn.txt"); Scanner in = new Scanner(dataIn.txt); While (____________) { String input = in.next(); System.out.println(input); }

(Multiple Choice)
4.8/5
(35)

Consider the following code snippet: Scanner in = new Scanner(. . .); In)useDelimiter("[A-Za-z]+"); What characters will be read in using this code?

(Multiple Choice)
4.8/5
(44)

Consider the following code snippet: Scanner in = new Scanner(. . .); While (in.hasNextInt()) { ) . . } Under which condition will the body of the while loop be processed?

(Multiple Choice)
4.8/5
(39)

When reading words with a Scanner object, a word is defined as ____.

(Multiple Choice)
4.7/5
(38)

Which of the following statements about exception reporting is true?

(Multiple Choice)
4.8/5
(36)

Your program wishes to open a file named C:\java\myProg\input.txt on a Windows system. Which of the following is the correct code to do this?

(Multiple Choice)
4.8/5
(34)

What is the purpose of the throw statement?

(Multiple Choice)
4.8/5
(36)

Which of the following statements about exception handling is recommended by the textbook?

(Multiple Choice)
4.8/5
(28)

Consider the following code snippet written in Java 7: Try (PrintWriter outputFile = new PrintWriter(filename)) { WriteData(outputFile); } Which of the following statements about this Java 7 code is correct?

(Multiple Choice)
4.9/5
(40)

Consider the following code snippet: Scanner in = new Scanner(. . .); While (in.hasNextInt()) { ) . . } Under which condition will the body of the while loop be processed?

(Multiple Choice)
4.9/5
(33)

Your program must read in an existing text file. You want the program to terminate if the file does not exist. Which of the following indicates the correct code for the main method header?

(Multiple Choice)
4.8/5
(40)

Consider the following code snippet: Scanner in = new Scanner(. . .); Int ageValue = in.nextInt(); If there is no integer number appearing next in the input, what will occur?

(Multiple Choice)
4.7/5
(35)

Consider the following code snippet: Public double[] readInputFile(String filename) throws IOException { File inputFile = new File(filename); Scanner in = new Scanner(inputFile); Try { ReadData(in); Return data; } Finally { InputFile.close(); } } Which of the following statements about this method's code is correct?

(Multiple Choice)
4.8/5
(42)

Consider the following code snippet. Scanner in = new Scanner(. . .); While (in.hasNextDouble()) { Double input = in.nextDouble(); } Which of the following statements about this code is correct?

(Multiple Choice)
4.8/5
(40)

Consider the following code snippet. Scanner in = new Scanner(. . .); While (in.hasNextLine()) { String input = in.nextLine(); } Which of the following statements about this code is correct?

(Multiple Choice)
4.8/5
(33)

Insert the missing code in the following code fragment. This fragment is intended to write an output file named dataOut.txt that resides in a folder named reports on the C: drive of a Windows system. Public static void main(String[] args) throws IOException { PrintWriter outputFile = _______; ) . . }

(Multiple Choice)
4.9/5
(36)

The Java compiler requires that your program handle which type of exceptions?

(Multiple Choice)
4.9/5
(42)

Which of the following statements about the finally clause in a try block is NOT true?

(Multiple Choice)
4.8/5
(38)

Consider the following code snippet: Public static void main(String[] args) throws FileNotFoundException Which of the following statements about this code is correct?

(Multiple Choice)
4.8/5
(36)
Showing 81 - 100 of 100
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)