Given code of Test.java file:
1. package com.sampleproject.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. try { //outer
6. try { //inner
7. System.out.println(1/0);
8. } catch(ArithmeticException e) {
9. System.out.println("INNER");
10. } finally {
11. System.out.println("FINALLY 1");
12. }
13. } catch(ArithmeticException e) {
14. System.out.println("OUTER");
15. } finally {
16. System.out.println("FINALLY 2");
17. }
18. }
19. }
What will be the result of compiling and executing Test class?
Given:

Consider below code:
1. package com.udayan.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. StringBuilder sb = new StringBuilder();
6. try {
7. for(;;) {
8. sb.append("OCA");
9. }
10. } catch(Exception e) {
11. System.out.println("Exception!!!");
12. }
13. System.out.println("Main ends!!!");
14. }
15. }
What will be the result of compiling and executing Test class?
Consider below code of Test.java file:
1. package com.sampleproject.oca;
2.
3. class Super {
4. public String num = "10"; //Line n1
5. }
6.
7. class Sub extends Super {
8. protected int num = 20; //Line n2
9. }
10.
11. public class Test {
12. public static void main(String[] args) {
13. Super obj = new Sub();
14. System.out.println(obj.num += 2); //Line n3
15. }
16. }
What will be the result of compiling and executing above code?
Given:


© Copyrights Oracledumps 2025. All Rights Reserved
We use cookies to ensure that we give you the best experience on our website (Oracledumps). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the Oracledumps.