Java Chapter 10

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

The __________ is an internal list of all methods that are currently executing.

Call stack

After a try block, a ______ clause appears.

Catch

The code in the ________ block is executed if the try block throws an exception.

Catch

All exceptions that are not derived from Error or RuntimeException are ____________ exceptions. These are the exceptions you should handle in your program.

Checked

____________________ this class allows you to read data of any primitive type or String objects from a binary file. The ____________________ class by itself cannot directly access a file, however. It is used in conjunction with a FileInputStream object that has a connection to a file.

DataInputStream

____________________ this class allows you to write data of any primitive type or String objects to a binary file. The ____________________ class by itself cannot directly access a file, however. It is used in conjunction with a FileOutputStream object that has a connection to a file.

DataOutputStream

If your code does not handle an exception when it is thrown, the ___________________________ deals with it.

Default exception handler

The process of reading a serialized object's bytes and constructing an object from them is known as _______________________.

Deserialization

The ____________ class is intended to be a superclass for exceptions that are thrown when a critical error occurs, such as an internal error in the Java Virtual Machine, or running out of memory. Your application should not try to handle these errors because they are a result of a serious condition.

Error

An _________________ is an object that is generated as the result of an error or an unexpected event.

Exception

You can create your own exception classes by deriving them from the _____________ class or one of its derived classes.

Exception

To detect that an exception has been thrown and prevent it from halting your application, Java allows you to create ___________________. an ___________________ is a section of code that gracefully responds to exceptions when they are thrown.

Exception handler(s)

The process of intercepting and responding to exceptions is called ___________________.

Exception handling

Internally the RandomAccessFile class keeps a long integer value known as the _____________. The _____________ holds the byte number of a location in the file.

File pointer

___________________ this class allows you to open a file for reading binary data and establish a connection with it. It provides only basic functionality for writing bytes to the file, however.

FileInputStream

___________________ this class allows you to open a file for writing binary data and establish a connection with it. It provides only basic functionality for writing bytes to the file, however.

FileOutputStream

The _________ block is one or more statements that are always executed after the try block has executed, and after any catch blocks have executed if an exception is thrown.

Finally

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

Finally

The ability to catch multiple types of exceptions with a single catch clause is known as ________________.

Multi-catch

Java allows a program to perform ___________ file access. In ___________ file access, a program can immediately jump to any location in the file without first reading the preceding bytes.

Random

To create and work with random access files in Java, you use the ___________________ class, which is in the java.io package

RandomAccessFile

All of the programs you have created to access files so far have performed __________________ file access. Which reads the file from the beginning.

Sequential

In order for an object to be serialized, its class must implement the _______________ interface. The _______________ interface has no methods or fields. It is used only to let the Java compiler know that objects of that class might be serialized.

Serializable

Java allows you to ________ objects, which is a simpler way of saving objects to a file.

Serialize

A ____________ is a list of all the methods in the call stack. It indicates the method that was executing when an exception occurred and all the methods that were called in order to execute that method.

Stack trace

All of the exception classes in the hierarchy are derived from the _____________ class.

Throwable

True or False: Don't confuse the throw statement with the throws clause. The throw statement causes an exception to be thrown. the throws clause informs the compiler that a method throws one or more exceptions

True

True or False: If an exception is not handled in other classes it must be handled in the main method, If the main method does not handle the exception the program is halted and the default exception handler handles the exception.

True

True or False: Storing data in its binary format is more efficient than storing it as text, because there are fewer conversions to take place.

True

True or False: The FileOutputStream constructor takes an optional second argument (the first argument being a filename) which must be a Boolean value. If the argument is true, the file will not be deleted if it already exists, and new data will be written to the end of the file.

True

True or False: The RandomAccessFile class treats a file as a stream of bytes. The bytes are numbered: -the first byte is byte 0. -The last byte's number is one less than the number of bytes in the file.

True

True or False: The catch clauses must be listed from most specific to most general.

True

True or False: The code in the try block may be capable of throwing more than one type of exception. A catch clause needs to be written for each type of exception that could potentially be thrown. The JVM will run the first compatible catch clause found.

True

True or False: The statements in the finally block execute whether an exception occurs or not.

True

True or False: When an object is serialized, it is converted into a series of bytes that contain the object's data. If the object is set up properly, even the other objects that it might contain as fields are automatically serialized. The resulting set of bytes can be saved to a file for later retrieval.

True

True or False: You can think of the code in the try block as being "protected" because the application will not halt if the try block throws an exception.

True

True or False: You can catch two exceptions like this: try { (try block statements) } catch (exception1 | exception2 ex) { (catch statements) }

True(this is called multi-catch)

To handle an exception, you use a _______ statement.

Try

A ______________ is one or more statements that are executed and can potentially throw an exception.

Try block

________________ exceptions, in most cases, should not be handled.

Unchecked

Each exception object has a method named ____________ that can be used to retrieve the default message for the exception.

getMessage

You can use the _______ statement to manually throw an exception.

throw

To write a string to a binary file, use the DataOutputStream class's __________ method. This method writes its String argument in a format known as UTF-8 encoding.

writeUTF


Ensembles d'études connexes

FT 2-3 Lesson 12 Spread Spectrum Technology

View Set

LESSON 34:EFFECTS OF SOIL EROSION

View Set

BUSA 379 CH 1 Introduction to Business Process Management

View Set

Matty C's CTS-I Practice Questions

View Set