Documentation with Comments MCQ Practice

Question 1 of 10

What text does this Java code display?

int coils = 9; // coils = 0;
System.out.print(coils);
  1. A. 0
  2. B. 9
  3. C. 1
  4. D. The comment is printed.

Question 2 of 10

What text does this Java code display?

int clay = 5;
clay += 3; /* extra note */
System.out.print(clay);
  1. A. 5
  2. B. 3
  3. C. 8
  4. D. The code cannot compile.

Question 3 of 10

Which statement best describes comments in Java?

  1. A. The compiler ignores them, and they are not executed when the program runs.
  2. B. They always change stored variable values.
  3. C. They are required to be printed by System.out.
  4. D. They replace the need for a compiler.

Question 4 of 10

What text does this Java code display?

System.out.print("Kiln");
/* System.out.print(" closed"); */
System.out.print(" ready");
  1. A. Kiln closed ready
  2. B. Kiln ready
  3. C. closed ready
  4. D. Kiln

Question 5 of 10

What text does this Java code display?

System.out.print("End /* note */");
  1. A. End
  2. B. note
  3. C. End /* note */
  4. D. Nothing

Question 6 of 10

A potter comments out two updates while testing a glaze formula. What text does this Java code display?

int gloss = 10;
/*
gloss -= 4;
gloss *= 2;
*/
System.out.print(gloss);
  1. A. 12
  2. B. 6
  3. C. 10
  4. D. 20

Question 7 of 10

A method is introduced with /** Sets the kiln to the given temperature. */ Which choice matches that comment form?

  1. A. A line comment that executes the set operation.
  2. B. A Javadoc comment used to document the method for API readers.
  3. C. A required compiler directive that assigns temperature.
  4. D. A string that prints automatically when the method is declared.

Question 8 of 10

What text does this Java code display?

int shelf = 2;
shelf++; // shelf += 5;
System.out.print(shelf);
  1. A. 7
  2. B. 2
  3. C. 3
  4. D. 8

Question 9 of 10

Which choice correctly matches each form to a typical use?

  1. A. // for the rest of one line; /* */ for a block that may span lines; /** */ for API documentation.
  2. B. /** */ executes arithmetic; // prints output; /* */ declares variables.
  3. C. // is the only form that can span three statements; /* */ cannot.
  4. D. All three forms are executed as if they were assignment statements.

Question 10 of 10

What text does this Java code display? Ignore a final trailing newline.

System.out.println("Wet");
// System.out.println("Trim");
System.out.print("Fire");
  1. A. Wet Trim Fire
  2. B. WetFire
  3. C. Wet Fire
  4. D. Wet // System.out.println("Trim"); Fire