Java Chapter 10 quiz

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Unchecked exceptions are those that inherit from the

Error class or the RuntimeException class

The throws clause causes an exception to be thrown (T/F)

false

If a random access file contains a stream of characters, which of the following statements would move the file pointer to the starting byte of the fifth character in the file?

file.seek(8);

When writing a string to a binary file or reading a string from a binary file, it is recommended that you use

methods that use UTF-8 encoding

Beginning in Java 7, you can use ________ to reduce a lot of duplicated code in a try statement that needs to catch multiple exceptions, but perform the same operation for each one.

multi-catch

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

FileInputStream and DataInputStream .

The catch clause

contains code to gracefully handle the exception type listed in the parameter list follows the try clause starts with the word catch followed by a parameter list in parentheses containing an ExceptionType parameter variable

To write data to a binary file, you create objects from the following classes:

FileOutputStream and DataOutputStream

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

It prints the error message for an exception.

If the data.dat file does not exist, what will happen when the following statement is executed? RandomAccessFile randomFile = new RandomAccessFile("data.dat", "rw");

The file data.dat will be created.

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

The inFile variable will reference an object that is able to read binary data from the Input.dat file.

If a program does not handle an unchecked exception, what is the result?

The program is halted and the default exception handler handles the exception.

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

WriteObject

This is a section of code that gracefully responds to exceptions when they are thrown.

exception handler

The throw statement informs the compiler that a method throws one or more exception. (T/F)

false

If a class has fields that are objects of other classes, those classes must implement the Serializable interface in order to be serialized. (T/F)

true

The ability to catch multiple types of exceptions with a single catch clause is known as multi-catch, and was introduced in Java 7. (T/F)

true

When catching multiple exceptions that are related to one another through inheritance, you should handle the more specialized exception classes before the more general exception classes. (T/F)

true

When you deserialize an object using the readObject method, you must cast the return value to the desired class type. (T/F)

true

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

try block


संबंधित स्टडी सेट्स

LD 51 POST Final, Flash Card Study set

View Set

Chapter 10 Drugs for Dyslipidemia Prep U

View Set

Spanish 2 - Lección 5 - Estructura: 5.3 Autoevaluación

View Set

MKT 4309 FINAL EXAM CH. 12, 13, 15, & 18

View Set

Abeka 10th: world literature- unit 12

View Set

FIN 3100 Chapter 5 Review Questions Interest Rates. Your Welcome :)

View Set

Chapter 1 Section 1.3 Peripheral Devices

View Set

Economics 101 - Chapter 6 - Unemployment

View Set

Digital Marketing - Google Certification

View Set

CH 12 Substance-Related and Addictive Disorders

View Set

Quiz: Mixing Medications From Two Vials in One Syringe

View Set