Exam 11: Exceptions and Advanced File IO
Exam 1: Introduction to Computers and Java51 Questions
Exam 2: Java Fundamentals61 Questions
Exam 3: Decision Structures64 Questions
Exam 4: Loops and Files57 Questions
Exam 5: Methods60 Questions
Exam 6: A First Look at Classes58 Questions
Exam 7: Arrays and the Arraylist Class64 Questions
Exam 8: A Second Look at Classes and Objects50 Questions
Exam 9: Text Processing and More About Wrapper Classes60 Questions
Exam 10: Inheritance70 Questions
Exam 11: Exceptions and Advanced File IO56 Questions
Exam 12: A First Look at GUI Applications60 Questions
Exam 13: Advanced GUI Applications58 Questions
Exam 14: Applets and More54 Questions
Exam 15: Creating GUI Applications With Javafx and Scene Builder40 Questions
Exam 16: Recursion42 Questions
Exam 17: Databases48 Questions
Select questions type
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:
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:
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:
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)
In order for an object to be serialized, its class must implement this interface.
(Multiple Choice)
4.8/5
(34)
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)
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
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)