Exam 11: Exceptions and Advanced File IO

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

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

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

B

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.

Free
(True/False)
4.7/5
(33)
Correct Answer:
Verified

True

If, within one try statement you want to have catch clauses that catch exceptions of the following types, in which order should they appear in your program? (1) Throwable (2) Exception (3) RuntimeException (4) NumberFormatException

Free
(Multiple Choice)
5.0/5
(28)
Correct Answer:
Verified

A

Why does the following code cause a compiler error? Try { Number = Integer.parseInt(str); } Catch (IllegalArgumentException e) { System.out.println("Bad number format."); } Catch (NumberFormatException e) { System.out.println(str + " is not a number."); }

(Multiple Choice)
4.9/5
(35)

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

(Multiple Choice)
4.8/5
(32)

The exception classes are in packages in the ________.

(Multiple Choice)
4.9/5
(36)

In order for an object to be serialized, its class must implement this interface.

(Multiple Choice)
4.8/5
(34)

When an exception is thrown:

(Multiple Choice)
4.8/5
(44)

A class must implement the Serializable interface in order for objects of the class to be serialized.

(True/False)
4.8/5
(35)

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

(Multiple Choice)
4.9/5
(28)

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

(Multiple Choice)
4.7/5
(40)

What will be the result of the following code? FileOutputStream fstream new FileOutputStream("Output.dat"); DataOutputStream outputFile = new DataOutputStream(fstream);

(Multiple Choice)
5.0/5
(33)

What will the following code display? String input = "99#7"; Int number; Try { Number = Integer.parseInt(input); } Catch(NumberFormatException ex) { Number = 0; } Catch(RuntimeException ex) { Number = 1; } Catch(Exception ex) { Number = -1; } System.out.println(number);

(Multiple Choice)
4.8/5
(26)

The try statement may have an optional ________ clause, which must appear after all of the catch clauses.

(Multiple Choice)
5.0/5
(35)

All exceptions are instances of classes that extend this class.

(Multiple Choice)
4.8/5
(33)

The following catch statement can: catch (Exception e) {…}

(Multiple Choice)
4.8/5
(30)

Unchecked exceptions are those that inherit from:

(Multiple Choice)
4.9/5
(43)

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

(Multiple Choice)
4.7/5
(45)

To read data from a binary file you create objects from the following classes:

(Multiple Choice)
5.0/5
(35)

Given the following constructor code, which of the statements are TRUE? 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
(47)
Showing 1 - 20 of 56
close modal

Filters

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