Arrays Quiz 2

By Mickey Arnold
Last updated 10 months ago
11 Questions

What is the output of System.out.println(vals[0]) on line 1?

What is the output of System.out.println(vals[2]) on line 2?

What is the output of System.out.println(vals[5]) on line 3?

What is the output of System.out.println(vals.length) on line 4?

What is the output of System.out.println(vals[1+5]) on line 5?

What is the output of System.out.println(vals[10/3]) on line 6?

What is the output of System.out.println(vals[2*2]) on line 7?

What is the output of System.out.println(vals[0] + vals[1]) on line 8?

What is the output of System.out.println(vals[1] + vals[4]) on line 9?

What is the output of System.out.println(vals.length/2) on line 10?

Run method description: Write a return method named run that returns an integer. run takes in one parameter which is an array of integers named one. run will return the sum of all values less than 5 in the array one. The call run([3,4,5,6,7,8,9,-2]) would return 5.