PHP - Interfaces and TraitsWhat 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'.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand interface constant visibilityConstants in interfaces are always public and cannot have other visibility modifiers.Step 2: Understand mutability of interface constantsConstants cannot be changed by implementing classes; they are fixed values.Final Answer:They are public by default and cannot be changed. -> Option AQuick 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 protectedTrying to change interface constants in classesUsing 'var' keyword for constants
Master "Interfaces and Traits" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Array Functions - Compact and extract functions - Quiz 8hard Classes and Objects - Properties and visibility - Quiz 6medium Error and Exception Handling - Why error handling matters - Quiz 5medium File Handling - Directory operations - Quiz 13medium File Handling - File pointer manipulation - Quiz 15hard Inheritance and Polymorphism - Abstract classes and methods - Quiz 8hard Sessions and Cookies - Destroying sessions - Quiz 5medium Sessions and Cookies - Session vs cookie decision - Quiz 6medium Superglobals and Web Context - $_GET for URL parameters - Quiz 1easy Superglobals and Web Context - $_FILES for file uploads - Quiz 15hard