MCQ Single Best Answer Not Set

QGiven the code. What is the result when this program is executed?
public class Test{
      static int x[];
    
      static{
            x[0] = 1;
      }
    
      public static void main(String args[]){
      }
}

ID: #2335 Java Exception MCQ 780 views
Question Info
#2335Q ID
Not SetDifficulty
Java Exception MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A ArrayIndexOutOfBoundsException is thrown
  • B ExceptionInInitializerError is thrown
  • C IllegalStateException is thrown
  • D StackOverflowException is thrown
Correct Answer: Option B

Explanation

ExceptionInInitializerError is thrown

Share This Question

Challenge a friend or share with your study group.