Oracle
1Z0-851 · Question #14
Which two code fragments correctly create and initialize a static array of int elements? (Choose two.)
The correct answer is A. static final int[] a = { 100,200 }; B. static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }. See the full explanation below for the reasoning.
Question
Which two code fragments correctly create and initialize a static array of int elements? (Choose two.)
Options
- Astatic final int[] a = { 100,200 };
- Bstatic final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }
- Cstatic final int[] a = new int[2]{ 100,200 };
- Dstatic final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }
How the community answered
(28 responses)- A71% (20)
- C18% (5)
- D11% (3)
Community Discussion
No community discussion yet for this question.