When does static type checking primarily occur in C++?

Options

  • A. Only while the program is running
  • B. During compilation
  • C. Only when the program is terminated
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. During compilation

Detailed Explanation

Correct Answer: Option B

Explanation:
Static type checking primarily occurs during compilation. The compiler checks whether operations are valid for the declared types. For example, assigning a string literal directly to an int variable is generally rejected by the compiler.