ch5 Flashcards

1
Q

What are the requirements for a switch expression?

A

It must evaluate to: char, byte, short, int, enum, String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the requirements for a case expression?

A

Evaluate to the same type as the switch expression. Compile-time constant.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is String comparison for case expressions case-senitive?

A

Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How many variables can you declare in the declaration part of a for loop?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many conditional expressions can a basic for loop contain?

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the possible causes of abrupt loop termination?

A

break, return, System.exit()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

break dummy; What happens, if no label with the name dummy exists?

A

compile error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can you use try and finally without a catch block?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens if the code contains a try block without catch or finally?

A

compile error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens if an exception is not caught at all?

A

The application stops running. The call stack will be printed to the output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Exceptions are always subclass of …?

A

java.lang.Exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

java.lang.Exception is a subclass of …?

A

Throwable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What can you use the throw keyword for?

A

Throwing anything which is instanceof Throwable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens if you have a catch block for IOException above the catch block of FileNotFoundException?

A

compiler error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly