Which keyword is commonly used to declare a read-only variable in C++?

Options

  • A. static
  • B. const
  • C. extern
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. const

Detailed Explanation

Correct Answer: B — const.

Explanation: The const keyword specifies that an object cannot be modified through that name after initialization, subject to C++ language rules. Example: const int MAX = 100;