Java OCA OCP Practice Question 915

Question

Which lines of output are displayed by the following program?

public class Main {
   public static void main(String[] args) {
      for (int i = 0; i < 10; ++i) {
         try {/*from  w w  w  .j av a2  s .co m*/
            try {
               if (i % 3 == 0)
                  throw new Exception("E0");
               System.out.println(i);
            } catch (Exception inner) {
               i *= 2;
               if (i % 3 == 0)
                  throw new Exception("E1");
            } finally {
               ++i;
            }
         } catch (Exception outer) {
            i += 3;
         } finally {
            --i;
         }
      }
   }
}
  • A. 4
  • B. 5
  • C. 6
  • D. 7
  • E. 8
  • F. 9


A and B.

Note

The program only displays the values 4 and 5.




PreviousNext

Related