PHP - Inheritance and PolymorphismWhich statement about the instanceof operator is FALSE?A<code>instanceof</code> returns false if the variable is nullB<code>instanceof</code> can check if a class exists in the current namespaceC<code>instanceof</code> throws a fatal error if used on a non-object variableD<code>instanceof</code> can be used to check if an object is an instance of a parent classCheck Answer
Step-by-Step SolutionSolution:Step 1: Review instanceof behavior with null and non-objectsinstanceof returns false for null and throws error for non-objects.Step 2: Check class existence checkinstanceof does NOT check if a class exists; use class_exists() instead.Final Answer:instanceof can check if a class exists in the current namespace is FALSE -> Option BQuick Check:instanceof does not check class existence = D [OK]Quick Trick: Use class_exists() to check class presence, not instanceof [OK]Common Mistakes:Thinking instanceof checks class existenceIgnoring error on non-object variablesAssuming instanceof returns true for null
Master "Inheritance and Polymorphism" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Array Functions - Why array functions matter - Quiz 13medium Classes and Objects - Properties and visibility - Quiz 4medium Classes and Objects - Destructor method - Quiz 13medium Error and Exception Handling - Error vs Exception in PHP - Quiz 3easy Inheritance and Polymorphism - Why inheritance is needed - Quiz 14medium Interfaces and Traits - Why traits are needed - Quiz 4medium Sessions and Cookies - Cookie expiration and security - Quiz 7medium String Functions - String comparison functions - Quiz 4medium String Functions - Trim functions - Quiz 11easy Superglobals and Web Context - $_POST for form submissions - Quiz 4medium