MCQs > IT & Programming > Java > What is wrong with the following code? class X extends Exception {} public class Y { public void foo() { try { b(); } finally { ba(); } catch (MyException e) {} } public void b() throws X { throw new X(); } public void ba() throws RuntimeException { throw new RuntimeException(); } }

Java MCQs

What is wrong with the following code?

 class X extends Exception {}
 public class Y
 {
     public void foo()
     {
     try {
         b();
     }
     finally {
         ba();
     }
     catch (MyException e) {}
     }
 public void b() throws X {
 throw new X();
 }
 public void ba() throws RuntimeException {
 throw new RuntimeException();
 }
 }

Answer

Correct Answer: Finally block should come after the catch block

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it