Problem statement:
Given the java code. what will be the output?
test
exception
runtime
end
Given the java code. what will be 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();
- throw new RuntimeException();
- } catch (RuntimeException ex) {
- System.out.println("runtime");
- System.out.println("end");
- }
- }
- }
test
exception
runtime
end
No comments:
Post a Comment