Exam 7: Inputoutput and Exception Handling

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

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)
5.0/5
(32)

Which Java class implements a file dialog box for selecting a file by a program with a graphical user interface?

(Multiple Choice)
4.8/5
(30)

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

The Scanner class's ____ method is used to specify a pattern for word boundaries when reading text.

(Multiple Choice)
4.8/5
(41)

Consider the following code snippet: If (in.hasNextDouble()) { Number = in.nextDouble(); } Result = in.next(); If the input contains the characters 626.14 average, what values will number and result have after this code is executed?

(Multiple Choice)
4.9/5
(39)

Which of the following statements about a PrintWriter object is true?

(Multiple Choice)
4.9/5
(31)

Under which condition will the Scanner constructor generate a FileNotFoundException?

(Multiple Choice)
4.8/5
(33)

Consider the following code snippet: Scanner in = new Scanner(. . .); In)useDelimiter("[^0-9]+"); What characters will be ignored and not read in using this code?

(Multiple Choice)
4.8/5
(43)

Which return value of the JFileChooser object's showOpenDialog method indicates that a file was chosen by the user at run time?

(Multiple Choice)
4.9/5
(42)

Insert the missing code in the following code fragment. This fragment is intended to read an input file named dataIn.txt and write to an output file named dataOut.txt. Public static void main(String[] args) throws FileNotFoundException { String inputFileName = "dataIn.txt"; String outputFileName = "dataOut.txt"; File inputFile = _________________; Scanner in = new Scanner(inputFile) ) . . }

(Multiple Choice)
4.7/5
(38)

When writing a method, which of the following statements about exception handling is true?

(Multiple Choice)
4.9/5
(37)

Consider the following code snippet: Try { PrintWriter outputFile = new PrintWriter(filename); Try { WriteData(outputFile); } Finally { OutputFile.close(); } } Catch (IOException exception) { ) . . } Which of the following statements about this code is correct?

(Multiple Choice)
4.9/5
(42)

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

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

(Multiple Choice)
4.8/5
(44)

Which of the following statements about reading and writing text files is correct?

(Multiple Choice)
4.8/5
(45)

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

(Multiple Choice)
4.8/5
(39)

Insert the missing code in the following code fragment. This fragment is intended to read a web page. Public static void main(String[] args) throws IOException { String address = "http://horstmann.com/index.html"; URL pageLocation = new URL(address); Scanner in = _________; ) . . }

(Multiple Choice)
4.7/5
(30)

The ____ method of the Character class will indicate if a character contains white space.

(Multiple Choice)
4.8/5
(34)

Which of the following statements about using a PrintWriter object is NOT true?

(Multiple Choice)
4.9/5
(38)

Consider the following code snippet. File inputFile = new File("dataIn.txt"); Scanner in = new Scanner(inputFile); While (in.hasNext()) { String input = in.next(); } Which of the following statements about this code is correct?

(Multiple Choice)
4.9/5
(36)
Showing 61 - 80 of 100
close modal

Filters

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