Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.) Which of the following is a correct way to declare an int array. 2.)Which of

ID: 3902763 • Letter: 1

Question

1.) Which of the following is a correct way to declare an int array.

2.)Which of the following to is a correct way to declare and initialize an array of integers with length 10?

3.)Which of the following is a correct way to declare and initialize an array with values 1,2,3,4,5 ?

4)What is x[0] in the following code?

int[ ] x = {1,2,3};

5)What type of data type would you create if a user wants to enter 50 names?

6)Will the following code compile or no?

int[ ] x = new int[3];

x = {1,2,3};

7)Each element in the array is represented using the following syntax, known as an ________ , ________ .  

8)You change a length of the array once it is initialized without reinitializing the array. True or False?

9)Look at the line of code below. Which of the following answer choices can be used to print the last element of array x?

String[ ] x = {"Tom", "Bob", "Jerry", "Cat"};

Note that the last element is "Cat", and x.length returns the size of the array (in this case, 4). Also notice that we use x.length for arrays, while for Strings, it is someString.length().

System.out.print(x[4]);

10)Which of the following to is a correct way to declare a String array?

11) How do you declare an array variable? (Write a code snippet.) Note that you aren't initializing anything yet, but simply declaring it?

a.) int[] array;

Explanation / Answer

1) a) int[] array;

2) a) int[] array=new int[10];

3) a) int[] array={1,2,3,4,5};

4) a) 1

5) a) String[] Array;

6) a) No, because you need to reinitialize the array if you do it this way.