What will print the following code:

public class ExceptionHandling {
    public static void main(String[] args) {
        double dbl = 1.0;
        try {
            dbl = dbl / 0;
            System.out.println("unreachable");
        } catch (ArithmeticException e) {
            System.out.println("reachable");
        } finally {
            System.out.println("reachable");
        }
        System.out.println("unreachable");
    }
}
Explanation
Division by zero for double will not lead to the ArithmeticException. The result will be Infinity, which is a special value for double and float types

unreachable reachable unreachable wil be printed

2018 Jan 10, 10:56:43 PM

Finally is not printing "finally". Please, fix. Also latest "unreachable" is not printed in the correct answer.

2017 Jun 19, 10:30:30 PM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты