Which will legally declare construct and initialise an array


Asked by admin @ in Chinese viewed by 518 People


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};

Answered by admin @



The only legal array declaration and assignment statement is Option D that is int myList [] = {4, 3, 7};
because


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 array.



Similar Questions

Which will legally declare construct and initialize an array

Asked by admin @ in Chinese viewed by 479 persons

Which will legally declare, construct, and initialize an array? A. int [] myList = {"1", "2", "3"}; B. int [] myList = (5, 8, 2); C. int myList [] [] …

Which of these is an incorrect array declaration

Asked by admin @ in Computer Science viewed by 282 persons

Which of these is an incorrect array declaration? a.int arr[] = new int[5] b.int [] arr = new int[5] c.int arr[] = new int[5] d.int arr[] = int [5] new?

Which of the following array declaration statement is illegal

Asked by admin @ in Computer Science viewed by 609 persons

Q. Which of the following Array declaration statement is illegal ? A. int[] a [ ] = new int [4] [4];B. int a[ ][ ] = new int [4] …

Which is an incorrect declaration of one dimensional array

Asked by admin @ in Computer Science viewed by 542 persons

Which of the following is an incorrect array declaration? a) int[] a = new int[20]; b)int [] a; c)int [] [] a = new int[20]; d)int [] [] a = …

Which of the following correctly declares an array

Asked by admin @ in Computer Science viewed by 294 persons

Which of the following correctly declares on array?

Overcoming fixed mindset: a step-by-step guide to cultivating a growth mindset

Asked by wiki @ in Health viewed by 1083 persons

Which of the following would best complete this list?

Asked by wiki @ in Social Studies viewed by 617 persons

What had the king decided to do before he saw the spider

Asked by vanshika149 @ in English viewed by 963 persons

Describe the karez in your own words

Asked by rajesh064 @ in English viewed by 1088 persons

What is 8 + (x + 5)?

Asked by jaylord7 @ in Mathematics viewed by 937 persons

What is the topic of the info grapher

Asked by jesus643 @ in History viewed by 1180 persons

Elephant kills 11 in nepal , woman rescued from a friendly dolphine

Asked by kavin044 @ in English viewed by 1095 persons

Most viewed questions in Chinese


Abiding values book by fr dabre joseph class 9 solutions

Asked by admin @ in Chinese viewed by 6959 persons


Games similar to a chinese ghost story in english

Asked by admin @ in Chinese viewed by 923 persons


Find the difference between given numbers 4352 and 5020

Asked by admin @ in Chinese viewed by 907 persons



What idea is emphasized through repetition warriors don t cry

Asked by admin @ in Chinese viewed by 709 persons


A wrong man in workers paradise summary in english

Asked by admin @ in Chinese viewed by 582 persons


What did the signing of the concordat of worms accomplish

Asked by admin @ in Chinese viewed by 548 persons



On what dates of april 2001 did sunday fall

Asked by admin @ in Chinese viewed by 545 persons


Summary of the lesson a wrong man in workers paradise

Asked by admin @ in Chinese viewed by 536 persons


Which will legally declare construct and initialise an array

Asked by admin @ in Chinese viewed by 518 persons



Oar is to rowboat as foot is to

Asked by admin @ in Chinese viewed by 492 persons


Which will legally declare construct and initialize an array

Asked by admin @ in Chinese viewed by 479 persons


The efficiency of steam turbine may be improved by

Asked by admin @ in Chinese viewed by 463 persons



Which element has highest melting point in 3d series

Asked by admin @ in Chinese viewed by 460 persons


Two vectors having equal magnitude a make an angle

Asked by admin @ in Chinese viewed by 455 persons


What are the limitations in obtaining energy from wind

Asked by admin @ in Chinese viewed by 432 persons