Java II Chapter 12: Exception Handling

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

The ____ class represents more serious errors from which your program usually cannot recover. a. Error b. Throwable c. Exception d. Menu REFERENCES: 595

a. Error

Assertions are meant to be helpful in the ____ stage of a program. a. development b. testing c. production d. modeling REFERENCES: 638

a. development

When you have actions you must perform at the end of a try...catch sequence, you can use a ____ block. a. finally b. catch c. throw d. try REFERENCES: 615

a. finally

A variable declared within a try or catch block is ____ to that block. a. local b. universal c. public d. unique REFERENCES: 606

a. local

A(n) ____ statement is one that sends an Exception object to a catch block. a. throw b. catch c. optional d. assert REFERENCES: 607

a. throw

The ____ option must be used when running a program in order to see the results of assert statements. a. -db b. -ea c. -debug d. -assert REFERENCES: 637

b. -ea

A catch block is a method that can be called directly and takes an argument that is some type of exception. a. True b. False REF

b. False

The code within a finally block cannot execute if the preceding try block identifies an exception. a. True b. False REFERENCES: 615

b. False

In the case where a method might throw more than one exception type, you specify a list of potential exceptions in the method header by separating them with ____. a. spaces b. semicolons c. commas d. periods REFERENCES: 625

c. commas

When you catch an Exception object, you can call ____________________ to display a list of methods in the call stack so you can determine the location of the statement that caused the exception. REFERENCES: 628

printStackTrace()

The parent class of Error is ____. a. Object b. Exception c. RuntimeError d. RuntimeException REFERENCES: 594-595

a. Object

Since variables declared within a try or catch block are local to that block, the variable goes out of scope when the try or catch block ends. a. True b. False REFERENCES: 606

a. True

To use a method to its full potential, you must know the method name, return type, type and number of arguments required, and type and number of exceptions the method throws. a. True b. False REFERENCES: 624

a. True

When an exception is a checked exception, client programmers are forced to deal with the possibility that an exception will be thrown. a. True b. False REFERENCES: 624

a. True

You can place as many statements as you need within a try block, and you can catch as many exceptions as you want. a. True b. False REFERENCES: 609

a. True

A(n) ____ clause is used in the method header so that applications that use your methods are notified of the potential for an exception. a. throws b. return c. stack d. exception REFERENCES: 624

a. throws

To create your own throwable Exception class, you must extend a subclass of Catchable. a. True b. False REFERENCES: 630

b. False

Unplanned exceptions that occur during a program's execution are also called execution exceptions. a. True b. False REFERENCES: 594

b. False

____ represents the degree to which a system is resilient to stress, maintaining correct functioning. a. Endurance b. Robustness c. Fault-tolerant d. Strength REFERENCES: 598

b. Robustness

What is the correct syntax of an assert statement? a. assert AssertionError : optionalErrorMessage b. assert booleanExpression : optionalErrorMessage c. assert stringExpression : optionalErrorMessage d. assert booleanExpression = optionalErrorMessage REFERENCES: 634

b. assert booleanExpression : optionalErrorMessage

The Java compiler does not require that you catch or specify ____ exceptions. a. checked b. runtime c. return d. optional REFERENCES: 625

b. runtime

In order to use a variable both with a try or catch block and afterward, you must declare the variable before the ____ block begins. a. catch b. try c. main d. finally REFERENCES: 606

b. try

____ exceptions are the type that programmers should anticipate and from which programs should be able to recover. a. Unchecked b. Runtime c. Checked d. Thrown REFERENCES: 623

c. Checked

Although a method can throw any number of ____ types, many developers believe that it is poor style for a method to throw and catch more than three or four types. a. Error b. Clause c. Exception d. Catch REFERENCES: 613

c. Exception

Which method constructor constructs a new exception with the specified detail message and cause? a. Exception() b. Exception(String message) c. Exception(String message, Throwable cause) d. Exception(Throwable cause) REFERENCES: 631

c. Exception(String message, Throwable cause)

____ statements are program statements that can never execute under any circumstances. a. Stagnant b. Error c. Unreachable d. Exception REFERENCES: 611

c. Unreachable

When you use a(n) ____ statement, you state a condition that should be true, and Java throws an AssertionError when it is not. a. if b. boolean c. assert d. exception REFERENCES: 634

c. assert

A(n) ____ is a Java language feature that can help you detect logic errors that do not cause a program to terminate, but nevertheless produce incorrect results. a.error checker b. thread c. assertion d. throw statement REFERENCES: 634

c. assertion

When a program contains multiple ____ blocks, they are examined in sequence until a match is found for the type of exception that occurred. a. throw b. finally c. catch d. try REFERENCES: 609

c. catch

If you want to ensure that a user enters numeric data, you should use ____ techniques that provide the means for your program to recover from the mistake. a. error-handling b. looping c. exception-handling d. decision REFERENCES: 638

c. exception-handling

Programs would be less clear if you had to account for ____ exceptions in every method declaration. a. unthrown b. thrown c. runtime d. checked REFERENCES: 625

c. runtime

Placing data conversion attempts in a try block allows you to handle potential data conversion errors caused by careless user entry. a. True b. False REFERENCES: 604

a. True

The keyword catch followed by an Exception type in the method header is used when a method throws an exception that it will not catch but that will be caught by a different method. a. True b. False REFERENCES: 599

b. False

The memory location known as the __________ is where the computer stores the list of method locations to which the system must return. REFERENCES: 626

call stack

Which of the following is NOT a component of a try block? a. a closing curly brace b. the keyword c. executable statements d. a throw statement REFERENCES: 599

d. a throw statement

Some programmers refer to a catch block as a catch ____. a. method b. phrase c. statement d. clause REFERENCES: 600

d. clause

If a method throws an exception that it will not catch but that will be caught by a different method, you must also use the keyword ____ followed by an Exception type in the method header. a. finally b. try c. catch d. throws REFERENCES: 621

d. throws

Any _____ block might throw an Exception for which you did not provide a catch block. REFERENCES: 616

try

The ___________ class comprises less serious errors that represent unusual conditions that arise while a program is running and from which the program can recover. REFERENCES: 595

Exception

If you create an object using Java's BigDecimal class, and then perform a division that results in a non-terminating decimal division such as 1/3, but specify that an exact result is needed, a(n) __________ is thrown. REFERENCES: 603

Arithmetic Expression


Set pelajaran terkait

chapter 10 environmental practice questions

View Set

Chapter 8: GDP: Measuring Total Production and Income

View Set

Planning Projects, Part 2 PROJECT TIME AND COST MANAGEMENT

View Set

Ch 16: Nursing Management During the Postpartum Period

View Set

International Business Law and its Environment CH1

View Set

ANTH370 Exam 3 (Quizzes 10-12) CSU

View Set