AP Computer Science Amediummcq1 pt

Which initialization causes a compile error?

A.int[] a = {1, 2.5};
B.int[] a = {1, 2};
C.int[] a = new int[2];
D.double[] d = {1.5, 2.5};

Explanation

Core Concept

A double cannot fit an int array.

Correct Answer

Aint[] a = {1, 2.5};

More Unit 6: Array practice questions

Try a random question →

Practice more AP Computer Science A questions with full explanations

Practice Unit 6: Array Questions →