Bird
0
0

What is true about constants declared inside a PHP interface?

easy📝 Conceptual Q1 of 15
PHP - Interfaces and Traits
What is true about constants declared inside a PHP interface?
AThey are public by default and cannot be changed.
BThey can be private or protected.
CThey can be changed by implementing classes.
DThey must be declared with the keyword 'var'.
Step-by-Step Solution
Solution:
  1. Step 1: Understand interface constant visibility

    Constants in interfaces are always public and cannot have other visibility modifiers.
  2. Step 2: Understand mutability of interface constants

    Constants cannot be changed by implementing classes; they are fixed values.
  3. Final Answer:

    They are public by default and cannot be changed. -> Option A
  4. Quick Check:

    Interface constants = public and immutable [OK]
Quick Trick: Interface constants are always public and unchangeable [OK]
Common Mistakes:
  • Thinking interface constants can be private or protected
  • Trying to change interface constants in classes
  • Using 'var' keyword for constants

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes