Which will legally declare, construct, and initialize an array?
A.int [] myList = {};
B.int [] myList = (5, 8, 2);
C.int myList [] [] = {4,9,7,0};
D.int myList [] = {4, 3, 7};
Answers
Answered by
0
______✨ HEY MATE ✨______
➡️Option (D) int myList [] = {4, 3, 7}; is the right answer ✔️
The only legal array declaration and assignment statement is Option D
Option A is wrong because it initializes an int array with String literals.
Option B is wrong because it uses something other than curly braces for the initialization.
Option C is wrong because it provides initial values for only one dimension, although the declared array is a two-dimensional array.
➡️Option (D) int myList [] = {4, 3, 7}; is the right answer ✔️
The only legal array declaration and assignment statement is Option D
Option A is wrong because it initializes an int array with String literals.
Option B is wrong because it uses something other than curly braces for the initialization.
Option C is wrong because it provides initial values for only one dimension, although the declared array is a two-dimensional array.
Similar questions
Physics,
7 months ago
Math,
7 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Biology,
1 year ago
Biology,
1 year ago
Biology,
1 year ago