Java Questionnaire

User Generated

cebgb_012

Programming

Description

Unformatted Attachment Preview

Question 1 10 pts Given the following code, enter the correct output for line System.out.println(colors.length): String[] colors = new String[15]; colors[@] = "Red"; colors[1] = "Blue"; colors[2] = "Green"; colors[3] = "Gray"; colors[4] = "White"; colors[5] = "Black"; System.out.println(colors.length); Question 2 10 pts Given the following code, select the correct output: String[] colors = new String[15]; colors[0] = "Red"; colors[1] = "Blue"; colors[2] = "Green" colors [3] = "Gray"; colors[4] = "White"; colors[5] = "Black"; int i = 1; System.out.println(colors[i++]); O Red O Blue o Green Gray White Black Question 3 10 pts Given the following bidimensional array, select the correct value of the sum variable. int[][] matrix = {{5,3,6}, {7,3,4}, {2,5,1}}; int sum = matrix[@][@] + matrix[1][1] + matrix[2][2]; Question 4 10 pts Given the following code, enter the value of total variable after execution: = int[] numbers = {4,6,2,7,8,3,2}; int total = @ for(int k = 0; k< numbers.length; k = k+2) total + numbers[k]; System.out.println(total); Question 5 10 pts Given the following source code, how many iterations are executed in the WHILE loop? int k = 20; while (k > 1) { System.out.println(k); k/=2; Question 6 10 pts Given the following source code, what is the value of sum after the loop has finished? int x = 10; int sum = 0; do { sum += x; X--; } while (x > 8); Question 7 10 pts Given the following source code, select the correct output: = int[] numbers = {4,6,2,7,8,3,9}; for(int j : numbers) if(j%3 > 0) continue; else System.out.print(j+" "); 04628 48 O 639 O 69 Question 8 10 pts Given the following source code, what is the value of total after the loop has finished? int total = 0; for (int i = 1; i
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Similar Content

Related Tags