G
gk
class Unchecked {
public static void main(String[] args) {
try {
method();
} catch (Exception e) {
}
}
static void method() {
try {
wrench();
System.out.println("a");
} catch (ArithmeticException e) {
System.out.println("b");
} finally {
System.out.println("c");
}
System.out.println("d");
}
static void wrench() {
throw new NullPointerException();
}
}
Question:
whats the output ?
i know whats the output ...because i have run it .....but problem is my
prediction and the real output did not match.
see, them method wrench throwing a null pointer exception.
can anybody please tell me the output in steps ?
i dont want to manipulate.
here are things so far........
method() calls wrench()
but wrench() thorws null pointer
this is caught in try-catch .....but there is no matching exception so
it will go to finally ...so "c' would be printed ....and at last d
is there ....so d would be printed.
so, predicted output is : c d
real output: c
question: why d is missing in the real output ?
public static void main(String[] args) {
try {
method();
} catch (Exception e) {
}
}
static void method() {
try {
wrench();
System.out.println("a");
} catch (ArithmeticException e) {
System.out.println("b");
} finally {
System.out.println("c");
}
System.out.println("d");
}
static void wrench() {
throw new NullPointerException();
}
}
Question:
whats the output ?
i know whats the output ...because i have run it .....but problem is my
prediction and the real output did not match.
see, them method wrench throwing a null pointer exception.
can anybody please tell me the output in steps ?
i dont want to manipulate.
here are things so far........
method() calls wrench()
but wrench() thorws null pointer
this is caught in try-catch .....but there is no matching exception so
it will go to finally ...so "c' would be printed ....and at last d
is there ....so d would be printed.
so, predicted output is : c d
real output: c
question: why d is missing in the real output ?