Documentation with Comments MCQ Practice

Question 1 of 10

What text does this Java code display?

int yeast = 3; // yeast = 11;
System.out.print(yeast);
  1. A. 11
  2. B. 3
  3. C. 0
  4. D. The code cannot compile.

Question 2 of 10

What text does this Java code display?

int flour = 8;
/* flour *= 2;
flour += 1; */
System.out.print(flour);
  1. A. 16
  2. B. 17
  3. C. 8
  4. D. 9

Question 3 of 10

What is the purpose of a Javadoc comment written with /** */?

  1. A. It is executed as a method call at run time.
  2. B. It is used to create API documentation for programmers.
  3. C. It converts int values into double values.
  4. D. It forces the compiler to ignore syntax errors.

Question 4 of 10

What text does this Java code display?

System.out.print("Mix // gently");
  1. A. Mix
  2. B. gently
  3. C. Mix // gently
  4. D. Nothing, because // starts a comment.

Question 5 of 10

What text does this Java code display?

System.out.print("A");
// System.out.print("B");
System.out.print("C");
  1. A. ABC
  2. B. AC
  3. C. A
  4. D. BC

Question 6 of 10

What text does this Java code display?

System.out.print("P"); /* System.out.print("Q");
System.out.print("R"); */
System.out.print("S");
  1. A. PQRS
  2. B. PS
  3. C. PRS
  4. D. PQS

Question 7 of 10

A baker writes // double the glaze next to an assignment. Which statement is true?

  1. A. The compiler executes the comment as if it were glaze *= 2;
  2. B. The comment is ignored at compile time and does not run.
  3. C. The comment prints itself when the program runs.
  4. D. The comment becomes a Javadoc page automatically because it uses //.

Question 8 of 10

What text does this Java code display?

int pans = 4;
pans += 2; // was pans += 9;
System.out.print(pans);
  1. A. 13
  2. B. 4
  3. C. 9
  4. D. 6

Question 9 of 10

Which comment form comments out exactly the rest of its source line and nothing on later lines?

  1. A. /* */ block comment only
  2. B. // line comment
  3. C. /** */ Javadoc only
  4. D. A string literal

Question 10 of 10

A student comments out a suspect line while testing. What text does this Java code display?

Line Source
1 int glaze = 5;
2 // glaze *= 4;
3 glaze += 3;
4 System.out.print(glaze);
  1. A. 20
  2. B. 8
  3. C. 5
  4. D. 23