What is output by the code below?
int[] array = {5,7,8,11,4};
out.println(array[0]);
a. 5
b. 7
c. 11
d. There is no output due to a syntax error.
e. There is no output due to a runtime exception.
What is output by the code below?
int[] array = {5,7,8,11,4};
out.println(array[1]);
a. 5
b. 7
c. 11
d. There is no output due to a syntax error.
e. There is no output due to a runtime exception.
What is output by the code below?
int[] array = {5,7,8,11,4};
out.println(array[5/2]);
a. 5
b. 7
c. 8
d. There is no output due to a syntax error.
e. There is no output due to a runtime exception.
Question 4. What is output by the code below?
int[] array = {5,7,8,11,4};
out.println(array[array.length-1]);
a. 4
b. 11
c. 8
d. There is no output due to a syntax error.
e. There is no output due to a runtime exception.
Question 5. What is output by the code below?
int[] array = {5,7,8,11,4};
out.println(array[array.length]);
a. 4
b. 11
c. 8
d. There is no output due to a runtime exception.
e. There is no output due to a syntax error.
Question 6. What is output by the code below?
int[] array = {5,7,8,11,4};
out.println(array.length);
a. 4
b. 2
c. 3
d. 1
e. 5
Question 7. What is output by the code below?
int[] array = {5,7,8,11,4};
for(int i=0; i<array.length/2; i=i+2)
{
array[i]=array[array.length-i-1];
}
System.out.println(array[0]);
a. 5
b. 7
c. 8
d. 4
e. 11
What is output by the code below?
int[] array = {5,7,8,11,4};
out.println(array[7/2]);
a. 5
b. 11
c. 8
d. There is no output due to a runtime exception.
e. There is no output due to a syntax error.
What is output by the code below?
int[] nums = new int[10];
for (int i=0; i < nums.length; i++)
{
nums[i] = i*2;
}
System.out.println(nums[5]);
a. 10
b. 12
c. 14
d. 16
e. 18
What is output by the code below?
int[] array = {5,7,8,11,4};
int sum = 0;
for(int i = 0; i<array.length; i++)
sum = sum + array[i];
System.out.println(sum);