Language Fundamentals

Q1: Which will legally declare, construct, and initialize an array?

A int [] myList = {"1", "2", "3"};

B int [] myList = (5, 8, 2);

C int myList [] [] = {4,9,7,0};

D int myList [] = {4, 3, 7};

ANS:D - int myList [] = {4, 3, 7};

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 use 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 arr



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.