Java Programming :: Exceptions
-
which answer most closely indicates the behavior of the program?public class MyProgram { public static void throwit() { throw new RuntimeException(); } public static void main(String args[]) { try { System.out.println("Hello world "); throwit(); System.out.println("Done with try block "); } finally { System.out.println("Finally executing "); } } }
-
At Point X on line 5, which code is necessary to make the code compile?public class ExceptionTest { class TestException extends Exception {} public void runTest() throws TestException {} public void test() /* Point X */ { runTest(); } }
-
and given that EOFException and FileNotFoundException are both subclasses of IOException, and further assuming this block of code is placed into a class, which statement is most true concerning this code?System.out.print("Start "); try { System.out.print("Hello world"); throw new FileNotFoundException(); } System.out.print(" Catch Here "); /* Line 7 */ catch(EOFException e) { System.out.print("End of file exception"); } catch(FileNotFoundException e) { System.out.print("File not found"); }
-
Which statement is true?
-
Which four can be thrown using the throw statement?
- Error
- Event
- Object
- Throwable
- Exception
- RuntimeException
-
Which statement is true?
A.
The program will not compile. |
B.
The program will print Hello world, then will print that a RuntimeException has occurred, then will print Done with try block, and then will print Finally executing. |
C.
The program will print Hello world, then will print that a RuntimeException has occurred, and then will print Finally executing. |
D.
The program will print Hello world, then will print Finally executing, then will print that a RuntimeException has occurred. |
A.
A try statement must have at least one corresponding catch block.
|
B.
Multiple catch statements can catch the same class of exception more than once.
|
C.
An Error that might be thrown in a method must be declared as thrown by that method, or be handled within that method.
|
D.
Except in case of VM shutdown, if a try block starts to execute, a corresponding finally block will always start to execute.
|