class Q29 {
public static void main(
String[] args) {
int j = 0;
Q29
test = new Q29();
try {
for (j=1 ; j < 5 ; j++)
{
j+= j;
}
int i = test.process() / (j = 5);
}
catch (Exception e) {
System.out.println(e);
System.out.println("Value of j = " + j);
}
}
int process() throws Exception {
throw new Exception("Exception Encountered");
}
}
What is the Output?
1.Prints Value of j = 2
2.Throws Arithmetic Exception.
3.Prints java.lang.Exception : Exception Encountered and Value of j = 7.
4.Prints Value of j = 10
5. Prints java.lang.Exception : Exception Encountered and Value of j = 2.
answer is 2:
can anyone explain.Thanks