int[] intArray; intArray = new int[4]; The following code declares an array that can store 5 items only starting from index 0 to 4. The following code declares an array that can store 4 items only starting from index 1 to 4. The following code declares an array that can store 4 items only starting from index 0 to 3. None of the above.
Added by Jack T.
Close
Step 1
Declare an integer array variable called "intArray". Show more…
Show all steps
Your feedback will help us improve your experience
Ivan Kochetkov and 91 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
'Which of the following correctly declares an array? int arr; int arr[array size]; array{array size}; array arr[array size];'
Rakesh S.
Which of the following correctly initializes an array arr to contain four elements each with value 0? $I$ int [] arr $=\{0,0,0,0\}$ II int [] arr $=$ new int [4] III int [] arr $=$ new int [4] for (int $i=0 ; \text { i }<\text { arr. length; } i++)$ $\operatorname{arr}[\mathrm{i}]=0$ (A) I only (B) III only (C) I and III only (D) II and III only (E) I, II, and III
Refer to the following code segment. You may assume that array arr 1 contains elements arr1 $[0], \operatorname{arr} 1[1], \ldots, \operatorname{arr} 1[\mathrm{N}-1],$ where $\mathrm{N}=\operatorname{arr} 1 .$ length. int count $=0$ for (int $i=0 ; \quad i < N ; \quad i++)$ if $(\operatorname{arr} 1[i] \quad !=0)$ { $\operatorname{arr} 1[\text { count }]=\operatorname{arr} 1[i]$ count++; 2 } int []$\text { arr } 2=\text { new int [count }]$ for (int $i=0 ; \text { i }< \text { count } ; \quad i++)$ $\operatorname{arr} 2[i]=\operatorname{arr} 1[i]$ If array arr 1 initially contains the elements 0,6,0,4,0,0,2 in this order, what will arr2 contain after execution of the code segment? (A) 6,4,2 (B) 0,0,0,0,6,4,2 (C) 6,4,2,4,0,0,2 (D) 0,6,0,4,0,0,2 (E) 6,4,2,0,0,0,0
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
100,000+
Students learning Computer Science with Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD