This code is meant to add up every element of pts. What does…
This code is meant to add up every element of pts. What does it actually print?int[][] pts = { {3, 4}, {5, 6}, {1, 2} }; int total = 0; for (int row = 0; row < pts.length; row++) { total = 0; for (int col = 0; col < pts[row].length; col++) { total += pts[row][col]; } } System.out.println(total);
Read DetailsThis loop is meant to remove every value less than 10. What…
This loop is meant to remove every value less than 10. What does the code print?ArrayList nums = new ArrayList(); nums.add(4); nums.add(6); nums.add(15); nums.add(3); for (int i = 0; i < nums.size(); i++) { if (nums.get(i) < 10) { nums.remove(i); } } System.out.println(nums.get(0) + " " + nums.size());
Read DetailsThis code prints a 4 by 4 square of # symbols. Which replace…
This code prints a 4 by 4 square of # symbols. Which replacement for the inner loop header makes it print a right triangle instead, with one # on the first line, two on the second, three on the third, and four on the fourth?for (int row = 1; row
Read DetailsWhat is printed by the following code?ArrayList temps = new…
What is printed by the following code?ArrayList temps = new ArrayList(); temps.add(72); temps.add(85); temps.add(91); temps.add(68); int checked = 0; for (int i = 0; i < temps.size(); i++) { checked++; if (temps.get(i) > 80) { break; } } System.out.println(checked);
Read Details