SCJP Module-6 Question-21


 

SCJP Module-6 Question-21

The sample program code will test your logic in Java programming and help you in better understating of Java program.

The sample program code will test your logic in Java programming and help you in better understating of Java program.

Given below the sample code :

class Main {
static String a = "&&";
public static void main(String[] args) {
new Main().a1();
System.out.println(a);
}
void a1() {
try {
a2();
} catch (Exception e) {
a += "x";
}
}
void a2() throws Exception {
a3();
a += "7";
a3();
a += "7x";
}
void a3() throws Exception {
throw new Exception();
}
}

What will be the output of the following code ?

1.Compilation error

2.&&7

3.&&7x

4.-x

Answer

(4)

Ads