Chapter 10

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The catch clause A) starts with the word catch followed by a parameter list in parentheses containing an ExceptionType parameter variable. B) follows the try clause. C) contains code to gracefully handle the exception type listed in the parameter list. D) All of these

All of these

In a catch statement, what does the following code do? A) It prints the error message for an exception. B) It prints the stack trace. C) It prints the code that caused the exception. D) It overrides the toString method.

It prints the error message for an exception.

In order for an object to be serialized, the class must implement this interface. A) Writable B) ObjectOutputStream C) Serial D) Serializable

Serializable

If you attempt to write to a file that does not exist using methods of a DataOutputStream object, what will happen? The file will be created for you. An checked exception will be thrown. An unchecked exception will be thrown. Spontaneous Java combustion.

The file will be created for you.

Which of the following objects or primitive types would be difficult to write out using methods of the ObjectOutputStream? A String object int boolean Integer Trick question: All the answers include serializable objects or data types!

Trick question: All the answers include serializable objects or data types!

If a method does not handle a possible checked exception, what must the method have? A) a catch clause in its header B) a try clause in its header C) a finally clause in its header D) a throws clause in its header

a throws clause in its header

The RandomAccessFile class treats a file as a stream of A) bytes. B) integers. C) characters. D) data.

bytes.

This is a section of code that gracefully responds to exceptions when they are thrown. A) exception handler B) exception C) default exception handler D) thrown class

exception handler

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? A) file.seek(8); B) file.seek(5); C) file.seek(4); D) file.seek(10);

file.seek(8);

Classes that inherit from the Error class are A) for exceptions that are thrown when an IOException error occurs, and the application program should try to handle them. B) for exceptions that are thrown when a critical error occurs, and the application program should not try to handle them. C) for exceptions that are thrown when an IOException occurs, and the application program should not try to handle them. D) for exceptions that are thrown when a critical error occurs, and the application program should try to handle them.

for exceptions that are thrown when a critical error occurs, and the application program should not try to handle them.

There exists a method in the RandomAccessFile class that returns the offset from the beginning of the file, in bytes, at which the next read or write occurs (a.k.a. the location of the pointer). Name this method. seek() length() getFilePointer() getFD()

getFilePointer()

An exception object's default error message can be retrieved using this method. A) getMessage B) getErrorMessage C) getDefaultErrorMessage D) getDefaultMessage

getMessage

When an exception is thrown, A) the program terminates even if the exception is handled. B) it may be ignored. C) it must always be handled by the method that throws it. D) it must be handled by the program or by the default exception handler.

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

Which method of the RandomAccessFile class returns the length of the file, measured in bytes? length() getSize() getLength() getBytes()

length()

When writing a string to a binary file or reading a string from a binary file, it is recommended that you use A) the FileReader and Writer class methods. B) methods that use UTF-8 encoding. C) the Scanner class methods. D) the System.In and System.Out methods.

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. A) catchAll B) multi-try C) multi-catch D) catch templates

multi-catch

The writeByte method of DataOutputStream writes out ___ byte(s). three two four one

one

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 A) the statement that appears immediately after the catch block. B) the last catch clause that can handle the exception. C) each catch clause that can handle the exception. D) the first catch clause that can handle the exception.

the first catch clause that can handle the exception.

A(n) ________ is one or more statements that are executed and can potentially throw an exception. A) error block B) try block C) exception block D) catch block

try block


Set pelajaran terkait

Chapter 1: Basic Elements Of C++

View Set

Lifetime Fitness and Wellness Unit 8 Lessons 1-2 & Quiz 1

View Set

khan academy answers computer science

View Set