GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

In a grade table, total and count are int variables holding…

In a grade table, total and count are int variables holding one row’s sum and its number of scores. Which expression gives the exact decimal average, such as 86.33 rather than 86?

Read Details

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 Details

A nested loop with the row loop on the outside prints a 2-ro…

A nested loop with the row loop on the outside prints a 2-row by 3-column grid in row-major order. To print it in column-major order (column by column) instead, what should change?

Read Details

This 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 Details

Assume ArrayList has been imported. Which line of this code…

Assume ArrayList has been imported. Which line of this code causes a compile error?ArrayList tags = new ArrayList(); tags.add(“clearance”); int n = tags.length; System.out.println(“Count: ” + n);

Read Details

This code is meant to find the largest value in lows. What d…

This code is meant to find the largest value in lows. What does it print?int[] lows = {-8, -3, -5}; int warmest = 0; for (int t : lows) { if (t > warmest) { warmest = t; } } System.out.println(warmest);

Read Details

What does this code print?int[] a = {4, 9, 2, 6}; a[1] = a[0…

What does this code print?int[] a = {4, 9, 2, 6}; a[1] = a[0] + a[3]; a[0] = 7; System.out.println(a[1]);

Read Details

What is printed by the following code?int battery = 15; if (…

What is printed by the following code?int battery = 15; if (battery > 50) { System.out.print(“full “); } else if (battery > 20) { System.out.print(“low “); } System.out.print(“checked”);

Read Details

This 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 Details

What 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

Posts pagination

Newer posts 1 … 8 9 10 11 12 … 100,399 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top