Try-catch statements

Report a typo

Which try-catch statements are correct?

a)

try {
    // code that may throw an exception
} catch (Exception e) {
    // ...
} catch (RuntimeException e) {
    // ...
}

b)

try {
    // code that may throw an exception
} catch (RuntimeException | Exception e) {
    // ...
}

c)

try {
    // code that may throw an exception
} catch (IndexOutOfBoundsException | NullPointerException e) {
    // ...
} catch (RuntimeException e) {
    // ...
}

d)

try {
    // code that may throw an exception
} catch (IndexOutOfBoundsException e) {
    // ...
} catch (RuntimeException e) {
    // ...
} catch (Exception e) {
    // ...
}
Select one or more options from the list
___

Create a free account to access the full topic