COSC 1437 CH10

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

Look at the following code: FileInputStream fstream = new FileInputStream("info.dat"); DataInputStream inputFile = new DataInputStream(fstream); This code can also be written as:

DataInputStream inputFile = new DataInputStream(new FileInputStream("info.dat"));

Unchecked exceptions are those that inherit from the

Error class or the RuntimeException class.

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 you write a method that throws a checked exception, you must

have a throws clause in the method header.

When an exception is thrown,

it must be handled by the program or by the default exception handler.

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 call stack is an internal list of all the methods that are currently executing.

True

When an object is serialized, it is converted into a series of bytes that contain the object's data.

True

The RandomAccessFile class treats a file as a stream of

bytes.

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

Exception

The throw statement informs the compiler that a method throws one or more exception.

False

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

FileOutputStream and DataOutputStream.

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

Serializable

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.

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

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.

True

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

WriteObject

A file that contains raw binary data is known as a(n)

binary file.

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

try block

In Java, there are two categories of exceptions:

unchecked and checked.


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

econ1. The demand curve represents the purchasing behavior of

View Set

Med Surg Exam 3 Practice Questions Part 5

View Set