Which exception or error will be thrown when a programmer attempts to run this code?

Given:
10. public class Foo {
11. static int[] a;
12. static { a[0]=2; }
13. public static void main( String[] args ) {}
14. }
Which exception or error will be thrown when a programmer attempts to run this code?

Given:
10. public class Foo {
11. static int[] a;
12. static { a[0]=2; }
13. public static void main( String[] args ) {}
14. }
Which exception or error will be thrown when a programmer attempts to run this code?

A.
java.lang.IllegalStateException

B.
java.lang.ArrayIndexOutOfBoundsException

C.
java.lang.StackOverflowError

D.
java.lang.ExceptionInInitializerError



Leave a Reply 0

Your email address will not be published. Required fields are marked *