PHP - Inheritance and PolymorphismWhich of the following statements about instanceof is TRUE?A<code>instanceof</code> can be used to check if a variable is nullB<code>instanceof</code> returns true if the object implements an interfaceC<code>instanceof</code> only works with built-in PHP classesD<code>instanceof</code> can check if a class existsCheck Answer
Step-by-Step SolutionSolution:Step 1: Review instanceof behavior with interfacesinstanceof returns true if the object implements the interface.Step 2: Check other optionsIt does not check null, class existence, or only built-in classes.Final Answer:instanceof returns true if the object implements an interface -> Option BQuick Check:instanceof works with interfaces = D [OK]Quick Trick: instanceof works with classes and interfaces [OK]Common Mistakes:Trying to use instanceof on null variablesAssuming instanceof only works with classesConfusing instanceof with function_exists
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