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

1.In the box below, create a 10 element array of type Integer called nums2. (Not

ID: 3858837 • Letter: 1

Question

1.In the box below, create a 10 element array of type Integer called nums2.

(Note: this should be an array of type Integer, not int.)

2.In the box below, use { } notation to create a 4 element array named nums3 of type int that holds the values: 10 20 30 40 in ascending order.

3.The array nums is a 10 element array of type int that has already been declared and initialized. Write the expression(s) in the box below that prints the sum of the first and second elements of nums to the console:


(Remember: the first element of an array is at index position 0).

Explanation / Answer

1.

          Integer nums2[] = new Integer[10];

The above statement will create an array of type integer that can store 10 elements starting from the index 0.

2.

          int nums3 []= {10,20,30,40};

The above statement will create an array of type integer that will store 4 elements specified in the {}. The array contains 10 at index 0, 20 at index 1, 30 at index 2, and 40 at index 3.

3.

            System.out.println(nums[0]+nums[1]);

The above statement will print the sum of first and second elements of the array nums.

First element is the element at index 0 and second element is the element at index 1.