Exam 7: Inputoutput and Exception Handling

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

The PrintWriter class is an enhancement of the ____ class.

Free
(Multiple Choice)
4.8/5
(44)
Correct Answer:
Verified

C

Consider the following code snippet. File hoursFile = new File("hoursWorked.txt"); Your program must read the contents of this file using a Scanner object. Which of the following is the correct syntax for doing this?

Free
(Multiple Choice)
4.7/5
(37)
Correct Answer:
Verified

C

Which of the following statements about command line arguments is correct?

Free
(Multiple Choice)
4.9/5
(41)
Correct Answer:
Verified

D

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

(Multiple Choice)
4.9/5
(37)

Insert the missing code in the following code fragment. This fragment is intended to read binary data. Public static void main(String[] args) throws IOException { String address = "http://horstmann.com/bigjava.gif"; URL imageLocation = new URL(address); InputStream in = _________; ) . . }

(Multiple Choice)
4.7/5
(37)

Which of the following is the correct syntax for starting a Java program named myProg from a command line if the program requires two arguments named arg1 and arg2 to be supplied?

(Multiple Choice)
4.9/5
(46)

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

(Multiple Choice)
4.7/5
(35)

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

(Multiple Choice)
4.8/5
(29)

Insert the missing code in the following code fragment. This fragment is intended to read binary data. Public static void main(String[] args) throws IOException { String address = "http://horstmann.com/bigjava.gif"; URL imageLocation = _________; InputStream in = imageLocation.openStream()); ) . . }

(Multiple Choice)
4.9/5
(35)

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

(Multiple Choice)
4.8/5
(41)

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

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

(Multiple Choice)
4.8/5
(29)

Consider the following code snippet: Public void readFile(String filename) throws FileNotFoundException { File inFile = new File(filename); Scanner in = new Scanner(inFile); ) . . } If the file cannot be located, which of the following statements about this code is correct?

(Multiple Choice)
4.8/5
(39)

You wish to use the Scanner class's nextInt() method to read in whole numbers. To avoid exceptions that would occur if the input is not a whole number, you should use the ____ method before calling nextInt.

(Multiple Choice)
4.8/5
(41)

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

(Multiple Choice)
4.9/5
(34)

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

Insert the missing code in the following code fragment. This fragment is intended to read an input file named hoursWorked.txt. You want the program to terminate if the file does not exist. Public static void main(String[] args) ______________ { File inputFile = new File("hoursWorked.txt"); Scanner in = new Scanner(inputFile); ) . . }

(Multiple Choice)
4.7/5
(38)

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

(Multiple Choice)
4.9/5
(40)

Which of the following statements about exception handling is correct?

(Multiple Choice)
5.0/5
(27)

When reading words using a Scanner object's next method, ____.

(Multiple Choice)
4.9/5
(43)
Showing 1 - 20 of 100
close modal

Filters

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