Exam 11: Inputoutput and Exception Handling

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

Consider the following code snippet: PrintWriter outputFile = new PrintWriter(filename); WriteData(outputFile); OutputFile.close(); How can the program ensure that the file will be closed if an exception occurs on the writeData call?

(Multiple Choice)
4.9/5
(38)

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

(Multiple Choice)
4.9/5
(34)

Consider the following code snippet: File inputFile = new File("input.txt"); You wish to read the contents of this file using a Scanner object. Which of the following is the correct syntax for doing this?

(Multiple Choice)
4.8/5
(38)

Which of the following statements about checked and unchecked exceptions is NOT true?

(Multiple Choice)
4.8/5
(45)

Which of the following statements about reading web pages is true?

(Multiple Choice)
4.7/5
(37)

Consider the following code snippet. Scanner inputFile = new Scanner("hoursWorked.txt"); Which of the following statements is correct?

(Multiple Choice)
4.7/5
(35)

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

(Multiple Choice)
4.8/5
(36)

Insert the missing code in the following code fragment. This fragment is intended to read an input file named dataIn.txt that resides in a folder named payroll on the C: drive of a Windows system. public static void main(String[] args) throws FileNotFoundException { File inputFile = ________; Scanner in = new Scanner(inputFile); ) . . }

(Multiple Choice)
4.9/5
(39)

Which of the following statements about reading and writing binary data is correct?

(Multiple Choice)
4.8/5
(47)

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

(Multiple Choice)
4.9/5
(39)

Under which condition will the Scanner constructor generate a FileNotFoundException?

(Multiple Choice)
4.8/5
(38)

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

(Multiple Choice)
4.8/5
(40)

Which of the following statements reflects the textbook's recommendations about closing files?

(Multiple Choice)
4.8/5
(39)

An example of a fatal error that rarely occurs and is beyond your control is the ____.

(Multiple Choice)
4.8/5
(43)

Which of the following is the correct syntax for creating a File object?

(Multiple Choice)
4.8/5
(34)

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
(52)

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.9/5
(33)

When you start a Java program from a command line and supply argument values, the values ____.

(Multiple Choice)
5.0/5
(42)

The PrintWriter class is an enhancement of the ____ class.

(Multiple Choice)
4.9/5
(35)

When a program throws an exception within a method that has no try-catch block, which of the following statements about exception handling is true?

(Multiple Choice)
4.9/5
(34)
Showing 81 - 100 of 109
close modal

Filters

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