Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
try catch finally
:
Content language: English
Русский
What is the result of the compilation and execution of the following code with the parameters a = 0, b = 3? public void divide(int a, int b) { try { int c = a / b; } catch (Exception e) { System.out.print("Exception "); } finally { System.out.println("Finally"); } }
try catch finally
What will be the result of the compilation and execution of the following code? 01. class A { 02. public void process() { System.out.print("A,"); } 03. } 04. public class B extends A { 05. public void process() throws IOException { 06. super.process(); 07. System.out.print("B,"); 08. throw new IOException(); 09. } 10. 11. public static void main(String[] args) { 12. try { new B().process(); } 13. catch (IOException e) { System.out.println("Exception"); } 14. } 15. }
try catch finally
What will happen when you try to compile and run the following code? It is assumed that the outstream file is already created. import java.io.*; public class Main { public static void main(String[] args) { try { FileInputStream fis = new FileInputStream("outstream"); InputStreamReader isr = new InputStreamReader(fis); BufferedReader br = new BufferedReader(isr); try { do { String str = br.readLine(); System.out.println(str); } while (str != null); } finally { fis.close(); isr.close(); br.close(); } } catch(IOException e){ e.printStackTrace(); } } }
try catch finally
What will be printed to standard output stream if a tryThis() method throws an IOException? try { tryThis(); return; } catch (IOException x1) { System.out.println("exception 1"); return; } catch (Exception x2) { System.out.println("exception 2"); return; } finally { System.out.println("finally"); }
try catch finally
Select the only correct program output when it is run by a "java Test 1 two 3" command. public class Test { static public void main(String[] args) { try { int k = Integer.parseInt(args[1]); System.out.println(args[k]); } catch (Exception e) { System.out.println(e); } } }
try catch finally
What is the result of the following code execution? public class Main { public static void main(String... args) { System.out.println("" + new Main().summ(3, 3)); } public int summ(int a, int b) { try { return a + b; } finally { if (a == b) return 0; } } }
try catch finally
try { int a = 0; int b = 42/a; System.out.print("A"); } catch (Exception e) { System.out.print("C"); } catch (ArithmeticException e) { System.out.print("B"); }
try catch finally
What will the following code fragment type: try { int i = 5; } catch (Exception e) { System.out.print("catch"); } finally { System.out.print("finally"); }
try catch finally
What will be the result of displaying this code? public class Main { static int method() { for (int i = 0; i < 5; i++) { System.out.println("i = " + i); try { if (i == 1) { throw new Exception(); } } catch (Exception e) { System.out.println("Exception!"); return i; } finally { System.out.println("Finally block"); } } return -1; } public static void main(String[] args) { System.out.println("method() returned " + method()); } }
try catch finally
What is the result of executing this code: try { int i = new Integer(10); System.out.println(i); } catch(Exception e) { System.out.println("opsss... error"); }
try catch finally
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes