Level 100 Level 102
Level 101

[Quiz] Exceptions, Threads & Assertions

30 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

In Java, the strange events that might cause a program to fail are called
Error & Exception
What are the two subclasses of the throwable class?
Runtime Exceptions
exceptions that usually occur because of code that isn't very robust.
exception that is thrown when your not properly checking to make sure that your code always stays within the bounds of an array
Exception that occurs when you're reading from a file and the file ends before you expected it to end.
isn't in the right format (perhaps a user typed it incorrectly)
try & catch
to "catch" a exception you must surround it with a _______ & _______
What try and catch effectively mean is:What try and catch effectively mean is:
Try this bit of code that might cause an exception.If it executes okay, go on with the program. If the code doesn't execute, catch the exception and deal with it.
catch clause
contains the class of exception to be caught and a variable name.
.getMessage() method
in all exceptions, and it displays a detailed error message describing what happened.
calls that led to the statement that generated the exception.
true or false: a class can only extend a single class
when writting multiple catch clauses you should always start with _______
more specific subclass exceptions and end with more general superclass exception catches (because if you start with a superclass exception catch you wont know what the specific exception was.
optional 3rd block of code in a try/catch that executes NO MATTER WHAT:
How does the substring() method of the String class work ?
the first argument specifies the index of the first character to include, the second argument indicates the index of the last character plus 1. A call to substring(2, 5) for a string would return the characters
If some code in your method's body might throw an exception, add the _______ keyword after the closing parenthesis of the method followed by the name or names of the exception
You must separate a list of fields with ...
the method _______ throw an exception if something goes wrong,
Error & RuntimeExceptions
In particular, exceptions of either the _______or _______ class or any of their subclasses do not have to be listed in your throws clause.
Unchecked exceptions
are usually thrown by the Java runtime itself.
if your method has been declared with a throws clause, don't forget to:
actually throw the exception in the body of your method using the throw statement.
an expression that is true
The assert keyword must be followed by one of three things:
assert price > 0 : "Price less than 0.";
How can you specify a string to make a assert statement more meaningful
does something else.
by subclassing the Thread class or implementing
A thread can be created in two ways:
start() method
To run a thread what method must be callled?
start() & run()
Calling a thread's _______ method causes its _______ method to be called
This method is the engine of a threaded class.
Ends execution of a method and possibly returns a value to the calling code.