Question

What is the output of the following Java code? try {     int[] arr = new int[3];     System.out.println(arr[5]); } catch (NullPointerException
e) {     System.out.println("NPE"); } catch (ArrayIndexOutOfBoundsException
e) {     System.out.println("AIOOBE"); } catch (Exception
e) {     System.out.println("Generic"); }

A Generic
B AIOOBE
C Compilation error: catch blocks in wrong order
D NPE
E The program crashes without printing anything
Practice Next

Hey! Ask a query

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)