Тесты
Язык сайта: Русский
Українська
English
Русский
Тесты по программированию
Вход
Регистрация
Тесты по программированию
Теория
сниппеты
Статьи
Главная
Android
Цены
FAQ
История Cosmo
Правила и условия сервиса
Политика конфиденциальности
Политика в отношении файлов cookie
Обратная Связь
try catch finally
:
Язык контента: English
Русский
Which of the following parts of the code will not cause the compilation errors?
try catch finally
What will be printed out as the result of the following code execution? public class Exceptions { public static void main(String[] args) { try { throw new UnsupportedOperationException(); } catch(Throwable t) { System.out.print("1"); } catch(Exception e) { System.out.print("2"); } catch(UnsupportedOperationException uoe) { System.out.print("3"); } } }
try catch finally
What will be printed as the result of the following program execution? public class C { public static void main(String[] args) { try { foo(); System.out.print("A "); } catch (Exception e) { System.out.print("B "); } finally { System.out.print("C "); } } private static void foo() throws Exception { try { System.out.print("A1 "); throw new Exception(); } catch (Exception e) { System.out.print("B1 "); throw new Exception(); } finally { System.out.print("C1 "); } } }
try catch finally
What is the output of following code: String s = "BIRD"; try { String x = "DOG"; throw new Exception(); } catch (Exception e) { s = "CAT"; } finally { s = "GOAT"; x = "FROG"; } System.out.println(s);
try catch finally
What will be the output of the following code? class Test { private int i; public void setI(int i) { this.i = i; } public int getI() { return i; } } public class Main { private Test t; public int getSomeInteger() { try { return t.getI(); } finally { return 0; } } public static void main(String[] args) throws Exception { Main m = new Main(); System.out.println(m.getSomeInteger()); } }
try catch finally
Can this method ever throw exception? public static int getTest() { try { // arbitrary code here } finally { return 1; } }
try catch finally
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"); } }
try catch finally
Is it possible to modify the following programm by inserting some code into the marked space to make it comply to the following conditions: - it finishes (no infinite loop) - it does not print "Finally"? class Clazz { public static void main(String[] args) { for (int i = 0; i < 2; i++) { try { System.out.println("Try"); // INSERT CODE HERE } finally { System.out.println("Finally"); } } } }
try catch finally
public class ExceptionTest { public static void errorHandling() { System.out.println("Error"); throw new IllegalAccessException(); } public static void main(String[] args) { try { errorHandling(); } catch (IllegalAccessException e) { System.out.println("Main error"); } } } What is the result of executing?
try catch finally
← Предыдущая
1
2
Следующая →
Зарегистрируйся сейчас
или
Подпишись на будущие тесты