Exam 11: Inputoutput and Exception Handling

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

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.8/5
(28)

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

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

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

(Multiple Choice)
4.8/5
(28)

Insert the missing code in the following code fragment. This fragment is intended to allow the user to select a file to be opened. JFileChooser chooser = new JFileChooser(); Scanner in = null; If (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { File selectedFile = __________; In = new Scanner(selectedFile); ) . . }

(Multiple Choice)
4.8/5
(30)

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 = new File(inputFileName); Scanner in = _________; ) . . }

(Multiple Choice)
4.8/5
(35)

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.8/5
(27)

Which method of the JFileChooser object will return the file object that describes the file chosen by the user at runtime?

(Multiple Choice)
4.8/5
(36)

Insert the missing code in the following code fragment. This code is intended to open a file and handle the situation where the file cannot be found. public void String readFile() _________________ { File inputFile = new File(. . .); Scanner in = new Scanner(inputFile); Try { While (in.hasNext()) { ) . . } } Finally { In)close(); } }

(Multiple Choice)
4.9/5
(33)

In the hierarchy of Exception classes, the NumberFormatException class is a subclass of the ____ class.

(Multiple Choice)
4.7/5
(42)

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

(Multiple Choice)
4.9/5
(32)

Insert the missing code in the following code fragment. This fragment is intended to read an input file. public static void main(String[] args) __________________ { String inputFileName = "dataIn.txt"; File inputFile = new File(inputFileName); Scanner in = new Scanner(inputFile); ) . . }

(Multiple Choice)
4.9/5
(26)

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

(Multiple Choice)
4.8/5
(36)

Consider the following code snippet: Scanner in = new Scanner(. . .); String result = ""; Int number = 0; If (in.hasNextInt()) { Number = in.nextInt(); } Result = in.next(); If the input begins with the characters 626.14 average, what values will number and result have after this code is executed?

(Multiple Choice)
4.7/5
(40)

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

Which of the following statements about white space in Java is correct?

(Multiple Choice)
4.8/5
(33)

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

Under which condition will the PrintWriter constructor generate a FileNotFoundException?

(Multiple Choice)
4.8/5
(37)

Which of the following patterns should be used for the delimiter to read one character at a time using a Scanner object's next method?

(Multiple Choice)
4.7/5
(44)

Consider the following code snippet. PrintWriter outFile = new PrintWriter("dataOut.txt"); Which of the following statements about the PrintWriter object is correct?

(Multiple Choice)
4.8/5
(26)
Showing 41 - 60 of 109
close modal

Filters

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