Questions: Code Comments and Style

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A developer writes: `total = price * quantity # multiply price by quantity`. A reviewer flags this comment. Why?

AThe comment is in the wrong location — it should be above the line, not inline
BThe comment restates what the code already shows and adds no useful information
CMultiplication should not be commented because it is a built-in operation
DThe variable names are unclear and should be fixed before any comment is added
Question 2 Multiple Choice

A programmer has a complex 20-line block that computes a priority score. They are about to write a long comment explaining the formula. What should they consider first?

AWhether the comment should be in the function header instead of inline
BWhether refactoring the code into a well-named function would eliminate the need for the comment
CWhether the programming language supports multi-line comment syntax
DWhether the formula has already been documented in external specifications
Question 3 True / False

Using consistent indentation and naming conventions matters more for long-term maintainability than which specific convention is chosen.

TTrue
FFalse
Question 4 True / False

Code that is well-named and clearly structured still requires comments on most lines to be considered professional quality.

TTrue
FFalse
Question 5 Short Answer

Why should comments explain 'why' rather than 'what,' and what kinds of 'why' are most valuable to document?

Think about your answer, then reveal below.