Expressions and Output MCQ Practice

Question 1 of 10

A materials list is printed with two println calls. What appears on the console? Treat choice line breaks as real line breaks and ignore a final trailing newline.

System.out.println("Zinc");
System.out.println("Lead");
  1. A. Zinc Lead
  2. B. ZincLead
  3. C. Zinc Lead
  4. D. Zinc Lead

Question 2 of 10

These statements print three int values. What text appears? Ignore a final trailing newline.

System.out.print(9);
System.out.print(1);
System.out.println(5);
  1. A. 15
  2. B. 9 1 5
  3. C. 915
  4. D. 9 1 5

Question 3 of 10

A studio sign uses a space that is printed as its own string. What is displayed? Choice line breaks are real. Ignore a final trailing newline.

System.out.print("On");
System.out.print(" ");
System.out.println("Air");
System.out.print("Now");
  1. A. OnAir Now
  2. B. On Air Now
  3. C. On Air Now
  4. D. On Air Now

Question 4 of 10

Which text does this statement display?

System.out.print("He yelled \"Go!\"");
  1. A. He yelled Go!
  2. B. He yelled "Go!"
  3. C. He yelled \"Go!\"
  4. D. The statement does not compile.

Question 5 of 10

What text does this literal display? Choice line breaks are real. Ignore a final trailing newline.

System.out.print("top\nbottom");
  1. A. top\nbottom
  2. B. topbottom
  3. C. top bottom
  4. D. top bottom

Question 6 of 10

A student types the statement below. What is the result?

System.out.print("Say "hi"");
  1. A. The console displays Say "hi".
  2. B. The console displays Say hi.
  3. C. The statement does not compile because the inner quotation marks are not escaped.
  4. D. The console displays Say hi and then a run-time error occurs.

Question 7 of 10

What value does Java produce for this expression?

(9 + 3) * 2
  1. A. 15
  2. B. 24
  3. C. 14
  4. D. 21

Question 8 of 10

What value does Java produce for this expression?

41 / 10 * 2
  1. A. 8.2
  2. B. 2
  3. C. 8
  4. D. 4

Question 9 of 10

What value does Java produce for this expression?

10 - 14 / 4
  1. A. 6.5
  2. B. 7
  3. C. -1
  4. D. 1

Question 10 of 10

Evaluate the expressions in the table, in row order. Which pair of results is correct?

Expression
7 / 2 * 2.0
7 / 2.0 * 2
  1. A. 6.0 and 7.0
  2. B. 7.0 and 7.0
  3. C. 6 and 6
  4. D. 3.5 and 7.0