CH 11. JAVA

Ace your homework & exams now with Quizwiz!

The ________________ tag in a method's documentation comment must appear after the general description of the method.

@exception

__________________ allows you to write data of any primitive type or String objects to a binary file. Cannot directly access a file. It is used in conjunction with aFileOutputStream object that has a connection to a file

DataOutputStream

_____________ and ______________ are derived from theThrowable class

Error, Exception

Most exceptions are derived from the _____________ class

Exception

The NumberFormatException class is derived from the _____________ class

Exception

When opening a file in "r" mode where the file does not exist, a ______________________ will be thrown

FileNotFoundException

____________________ allows you to open a file for writing binary data. It provides only basic functionality for writing bytes to the file

FileOutputStream

Opening a file in "r" mode and trying to write to it will throw an ____________________

IOException

The NumberFormatException class is derived from the _____________________________ class.

IllegalArgumentException

Exception objects are created from classes in the ___________ _________ hierarchy of exception classes

JAVA API

Beginning in _________ ___ you can specify more than one exception in a catch clause

Java 7

The ______________________ class is designed to perform the serialization process

ObjectOutputStream

To create and work with random access files in Java, you use the ___________________ class

RandomAccessFile

_____________________ serves as a superclass for exceptions that result from programming errors.

RuntimeExceptions

___________ exceptions are those that are derived from the Error class or the RuntimeException class

Unchecked

_________________ exceptions will crash a program

Unhandled

A file that contains binary data is often called a ___________ ___________.

binary file

The FileOutputStream constructor takes an optional second argument which must be a ______________ value

boolean

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

call stack

After the try block, a _____________ clause appears

catch

The JVM will run the first compatible _________ clause found

catch

What are the 2 categories of exceptions?

checked, unchecked

If there is no exception handler inside the method:

control of the program is passed to the previous method in the call stack

The ______________ exception handler deals with unhandled exceptions

default

The _______________ exception handler prints an error message and crashes the program

default

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

deserialization

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

exception

An _________________ ______________ is a section of code that gracefully responds to exceptions

exception handler

The process of intercepting and responding to exceptions is called _______________ ____________

exception handling

T/F After an exception, the program will not continue execution at the point just past the catch block

false

T/F The code in the try block is not capable of throwing more than one type of exception

false

The _______ ____________ holds the byte number of a location in the file

file pointer

If present, the _____________ clause must appear after all of the catch clauses

finally

The statements in the _____________ block execute whether an exception occurs or not

finally

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

getMessage

An exception is an ____________

object

The Integer class's _____________ method throws a NumberFormatException object

parseInt

When handling exceptions, you can use a _______________ reference as a parameter in the _____________ clause

polymorphic, catch

In _______________ file access, a program may immediately jump to any location in the file

random

The way data is stored in memory is sometimes called the ________ _________ _________.

raw binary format

The ______________ method returns the deserialized object

readObject

The DataInputStream class's _________________ method reads from the file

readUTF

In RandomAccessFile, "r" means:

reading

In RandomAccessFile, "rw" means:

reading and writing

If you open a file in "_____" mode and the file does not exist, it will be created

rw

Text files and the binary files previously shown use _______________ file access

sequential

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

stack trace

The _________ class, as many others in the Java API, implements the Serializable interface

string

Find the 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."); }

swap NFE and IAE (error is second catch)

The ____________ statement is used to manually throw an exception

throw

All of the exception classes in the hierarchy are derived from the _______________ class

throwable

Exception are said to have been ______________

thrown

The __________ clause informs the compiler what exceptions can be thrown from a method

throws

T/F A catch clause needs to be written for each type of exception that could potentially be thrown

true

T/F A catch clause that uses a parameter variable of the Exception type is capable of catching any exception that is derived from theException class

true

T/F A try statement may have only one catch clause for each specific type of exception

true

T/F All exceptions that are not derived from Error or RuntimeException are checked exceptions

true

T/F If the argument is true, the file will not be erased if it exists; new data will be written to the end of the file

true

T/F Storing data in its binary format is more efficient than storing it as text

true

T/F The Serializable interface has no methods or fields

true

T/F The application will not halt if the try block throws an exception

true

T/F The catch clauses must be listed from most specific to most general

true

T/F The code in the catch block is executed if the try block throws an exception

true

T/F The following code will write a string to a file: String name = "Chloe"; outputFile.writeUTF(name)

true

T/F The parameter must be of a type that is compatible with the thrown exception's type

true

T/F There can be many polymorphic catch clauses.

true

T/F When an exception is thrown, it cannot be ignored

true

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

true

T/F the following code will read a string from a file: String name = inputFile.readUTF();

true

To handle an exception, you use a _________ statement

try

A DataOutputStream object is ___________ around a FileOutputStream object to write data to a binary file

wrapped

To serialize an object and write it to the file, theObjectOutputStream class's _____________ method is used

writeObject

To write a string to a binary file, use theDataOutputStream class's _______________ method

writeUTF

When you want to separate exceptions which symbol should you use

|


Related study sets

Econ 102: Externalities and Public Goods

View Set

Teaching Vocabulary: Growing and Processing Bananas

View Set

SLMC Principles of Speech FINAL (Ch. 7-12)

View Set

Chapter 7 - The Valuation and Characteristics of Bonds

View Set

Fundamentals of Computer Science Exam 1 Review

View Set

Chapter 6 Introduction to Business

View Set

International Business Law: Chapter 7

View Set

Foundations Chapter 35 Sexuality

View Set