ch5 Flashcards
What are the requirements for a switch expression?
It must evaluate to: char, byte, short, int, enum, String
What are the requirements for a case expression?
Evaluate to the same type as the switch expression. Compile-time constant.
Is String comparison for case expressions case-senitive?
Yes.
How many variables can you declare in the declaration part of a for loop?
0, 1 or many. If you declare multiple variables: they must be of the same type, you have to separate them with a comma.
How many conditional expressions can a basic for loop contain?
1
What are the possible causes of abrupt loop termination?
break, return, System.exit()
break dummy;
What happens, if no label with the name dummy exists?
compile error
Can you use try
and finally
without a catch
block?
yes
What happens if the code contains a try
block without catch
or finally
?
compile error
What happens if an exception is not caught at all?
The application stops running. The call stack will be printed to the output.
Exceptions are always subclass of …?
java.lang.Exception
java.lang.Exception is a subclass of …?
Throwable
What can you use the throw
keyword for?
Throwing anything which is instanceof Throwable
What happens if you have a catch
block for IOException
above the catch block of FileNotFoundException
?
compiler error