Which will legally declare construct and initialize an array


Asked by admin @ in Chinese viewed by 499 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 initialise an array

Asked by admin @ in Chinese viewed by 537 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 293 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 618 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 558 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 302 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 1237 persons

Which of the following would best complete this list?

Asked by wiki @ in Social Studies viewed by 707 persons

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

Asked by vanshika149 @ in English viewed by 1099 persons

Describe the karez in your own words

Asked by rajesh064 @ in English viewed by 1256 persons

What is 8 + (x + 5)?

Asked by jaylord7 @ in Mathematics viewed by 1053 persons

What is the topic of the info grapher

Asked by jesus643 @ in History viewed by 1345 persons

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

Asked by kavin044 @ in English viewed by 1221 persons

Most viewed questions in Chinese


Abiding values book by fr dabre joseph class 9 solutions

Asked by admin @ in Chinese viewed by 7007 persons


Games similar to a chinese ghost story in english

Asked by admin @ in Chinese viewed by 945 persons


Find the difference between given numbers 4352 and 5020

Asked by admin @ in Chinese viewed by 920 persons



What idea is emphasized through repetition warriors don t cry

Asked by admin @ in Chinese viewed by 733 persons


A wrong man in workers paradise summary in english

Asked by admin @ in Chinese viewed by 599 persons


What did the signing of the concordat of worms accomplish

Asked by admin @ in Chinese viewed by 565 persons



On what dates of april 2001 did sunday fall

Asked by admin @ in Chinese viewed by 564 persons


Summary of the lesson a wrong man in workers paradise

Asked by admin @ in Chinese viewed by 549 persons


Which will legally declare construct and initialise an array

Asked by admin @ in Chinese viewed by 537 persons



Oar is to rowboat as foot is to

Asked by admin @ in Chinese viewed by 509 persons


Which will legally declare construct and initialize an array

Asked by admin @ in Chinese viewed by 499 persons


Which element has highest melting point in 3d series

Asked by admin @ in Chinese viewed by 483 persons



The efficiency of steam turbine may be improved by

Asked by admin @ in Chinese viewed by 480 persons


Two vectors having equal magnitude a make an angle

Asked by admin @ in Chinese viewed by 473 persons


What are the limitations in obtaining energy from wind

Asked by admin @ in Chinese viewed by 446 persons