Home / CSE MCQs / Data Structure MCQs :: Discussion

Discussion :: Data Structure MCQs

  1. What is the output of the following piece of code?

    public class array
    {
    public static void main(String args[])
    {
    int []arr = {1,2,3,4,5};
    System.out.println(arr[5]);
    }
    }
  2. A.
    4
    B.
    5
    C.
    ArrayIndexOutOfBoundsException
    D.
    InavlidInputException

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Trying to access an element beyond the limits of an array gives ArrayIndexOutOfBoundsException.


Be The First To Comment