Object Oriented Concept - Study Mode
[#116] Which keyword is used to access a static method or property from within the same class(rather than from child)?
Correct Answer
(C) self
Explanation
Solution: Self is to classes what the $this pseudo-variable is to objects.
[#117] In which of the following circumstance should you use a static reference to a non static method?
Correct Answer
(A) Making a method call using parent
Explanation
Solution: Making a method call using parent is the only circumstance in which you should use a static reference to a non-static method.
[#118] Which one of the following variable cannot be used inside a static method?
Correct Answer
(A) $this
Explanation
Solution: By definition, static methods are not invoked in the context of an object. For this reason, static methods and properties are often referred to as class variables and properties.
[#119] Which one of the following is the correct abstract method?
Correct Answer
(D) abstract public function write()
Explanation
Solution: An abstract method cannot have an implementation. You declare it in the normal way, but end the declaration with a semicolon rather than a method body.
[#120] What will be the output of the following PHP code? <?php class MyClass
{
}
$a = new MyClass
var_dump(!( $a instanceof stdClass ))
?>
Correct Answer
(A) bool(true)
Explanation
Solution: To check if an object is not an instanceof a class, the logical not operator can be used.