Zend
200-710 · Question #39
What is the output of the following code? class Base { protected static function whoami() { echo "Base "; } public static function whoareyou() { static::whoami(); } } public static function whoami()…
The correct answer is C. Base B B A B. See the full explanation below for the reasoning.
Object-Oriented Programming
Question
What is the output of the following code?
class Base {
protected static function whoami() {
echo "Base ";
}
public static function whoareyou() {
static::whoami();
}
}
public static function whoami() {
echo "A ";
}
class A extends Base {
public static function test() {
Base::whoareyou();
self::whoareyou();
parent::whoareyou();
A::whoareyou();
static::whoareyou();
}
}
class B extends A {
public static function whoami() {
echo "B ";
}
}
B::test();
Options
- AB B B B B
- BBase A Base A B
- CBase B B A B
- DBase B A A B
How the community answered
(49 responses)- A8% (4)
- B12% (6)
- C76% (37)
- D4% (2)
Topics
#late static binding#static::#self::#inheritance method resolution
Community Discussion
No community discussion yet for this question.