Difficulty: Easy
Correct Answer: Both A and B.
Explanation:
Introduction:
C++ performs compile-time type checking and also offers limited runtime type identification features. This question verifies understanding of static versus dynamic type checking and clarifies a common misconception about const qualification of static member functions.
Given Data / Assumptions:
Concept / Approach:
“Static type checking” means errors are caught at compile time by the type system. “Dynamic type checking” in C++ refers to features like dynamic_cast on polymorphic types and typeid, which consult runtime type information. A static member function cannot be declared const because const applies to the implicit object parameter (this), which static functions do not have.
Step-by-Step Solution:
1) Assess statement A: true — the C++ compiler enforces static type rules at compile time.2) Assess statement B: true — RTTI enables certain runtime checks (e.g., dynamic_cast failures).3) Assess statement C: false — static members lack a this pointer; const has no meaning here.4) Therefore the correct combined choice is “Both A and B.”
Verification / Alternative check:
Code examples: dynamic_cast
Why Other Options Are Wrong:
A only: ignores legitimate runtime checks via RTTI.B only: overlooks pervasive compile-time checking in C++.C: impossible by language rules; const qualifies the object state through this.
Common Pitfalls:
Confusing dynamic typing (as in Python) with C++’s RTTI; C++ remains statically typed even though it supports certain runtime checks.
Final Answer:
Both A and B.
Discussion & Comments