Pagina de inicio
/
Tecnología
/
Which of the following are valid arrays? I int[]coolArray= 1,2,3 II . int[] threeThings = (1.8, 2.8,3.8) int[]threeThings={ 1.0,2.0,3.0 III int[]= ''1'',''2'',''3'' II only III only I and II I only I and III

Problemas

Which of the following are valid arrays?
I int[]coolArray= 1,2,3 
II . int[] threeThings = (1.8, 2.8,3.8) int[]threeThings={ 1.0,2.0,3.0 
III int[]= ''1'',''2'',''3'' 
II only
III only
I and II
I only
I and III

Which of the following are valid arrays? I int[]coolArray= 1,2,3 II . int[] threeThings = (1.8, 2.8,3.8) int[]threeThings={ 1.0,2.0,3.0 III int[]= ''1'',''2'',''3'' II only III only I and II I only I and III

Solución

avatar
Armandoveterano · Tutor durante 9 años
expert verifiedVerificación de expertos
4.0 (194 votos)

Responder

I only<br /><br />Explanation:<br />I. $int[]coolArray=\{ 1,2,3\} $ is a valid array declaration and initialization in Java. It declares an integer array named "coolArray" and initializes it with the values 1, 2, and 3.<br /><br />II. The declaration `int[] threeThings = {1.8, 2.8,3.8)` is not valid because the values are not integers. The correct declaration should be `double[] threeThings = {1.8, 2.8, 3.8}`.<br /><br />III. $int[]=\{ ''1'',''2'',''3''\} $ is not valid because the values are strings, not integers. The correct declaration should be `String[] coolArray = {"1", "2", "3"}`.
Haz clic para calificar: