Problem statement:
Given the code of java. Find out the output.
Given the code of java. Find out the output.
- public class Test {
- static void test() throws RuntimeException {
- try {
- System.out.println("test");
- throw new RuntimeException();
- } catch (Exception ex) {
- System.out.println("exception");
- }
- }
- public static void main(String[] args) {
- try {
- test();
- } catch (RuntimeException ex) {
- System.out.println("runtime");
- }
- System.out.println("end");
- }
- }
Output:
test
exception
end
end
No comments:
Post a Comment