Exam 11: Exceptions and Advanced File Io

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

When an exception is thrown by code in its try block, the JVM begins searching the try statement for a catch clause that can handle it and passes control of the program to __________.

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

C

The IllegalArgumentException class extends the RuntimeException class and is, therefore, __________.

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

B

A(n) __________ is a section of code that gracefully responds to exceptions when they are thrown.

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

C

To serialize an object and write it to the file, use the __________ method of the ObjectOutputStream class.

(Multiple Choice)
4.9/5
(82)

All of the exceptions you will handle are instances of classes that extend the __________ class.

(Multiple Choice)
4.8/5
(78)

The catch clause __________.

(Multiple Choice)
4.8/5
(76)

What happens if a program does not handle an unchecked exception?

(Multiple Choice)
4.8/5
(84)

An exception's default error message can be retrieved by using the __________ method.

(Multiple Choice)
4.9/5
(78)

A(n) __________ contains one or more statements that are executed and can potentially throw an exception.

(Multiple Choice)
4.9/5
(71)

If a method does not handle a possible checked exception, what must the method have?

(Multiple Choice)
4.7/5
(91)

Assume that the classes BlankISBN, NegativePrice, and NegativeNumberOrdered are exception classes that inherit from Exception. The following code is a constructor for the Book class. What must be true about any method that instantiates the Book class with this constructor? public Book(String ISBNOfBook, double priceOfBook, Int numberOrderedOfBook) { If (ISBNOfBook == "") Throw new BlankISBN(); If (priceOfBook < 0) Throw new NegativePrice(priceOfBook); If (numberedOrderedOfBook < 0) Throw new NegativeNumberOrdered(numberOrderedv); ISBN = ISBNOfBook; Price = priceOfBook; NumberedOrdered = numberOrderedOfBook; }

(Multiple Choice)
4.8/5
(85)

If your code does not handle an exception when it is thrown, __________ prints an error message and crashes the program.

(Multiple Choice)
4.9/5
(69)

In a catch statement, what does the following code do? System.out.println(e.getMessage());

(Multiple Choice)
4.9/5
(88)

To write data to a binary file, you create objects from which of the following classes?

(Multiple Choice)
4.8/5
(95)

In Java there are two categories of exceptions which are __________.

(Multiple Choice)
4.9/5
(89)

In the following code, assume that inputFile references a Scanner object that has been successfully used to open a file: double totalIncome = 0.0; While (inputFile.hasNext()) { Try { TotalIncome += inputFile.nextDouble(); } Catch(InputMismatchException e) { System.out.println("Non-numeric data encountered " + "in the file."); InputFile.nextLine(); } Finally { TotalIncome = 35.5; } } What will be the value of totalIncome after the following values are read from the file? 2)5 8)5 3)0 5)5 Abc 1)0

(Multiple Choice)
4.8/5
(80)

All of the exceptions that you will handle are instances of classes that extend the __________ class.

(Multiple Choice)
4.8/5
(76)

What will be the result of the following statements? FileInputStream fstream = new FileInputStream("Input.dat"); DataInputStream inFile = new DataInputStream(fstream);

(Multiple Choice)
4.9/5
(80)

If the class SerializedClass contains references to objects of other classes as fields, those classes must also implement the Serializable interface in order to be serialized.

(True/False)
4.7/5
(62)

To read data from a binary file, you create objects from which of the following classes?

(Multiple Choice)
4.7/5
(84)
Showing 1 - 20 of 59
close modal

Filters

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