PrepAway - Latest Free Exam Questions & Answers

What is the output of the following code?

What is the output of the following code? class Base { protected static function whoami() {
echo “Base “; } public static function whoareyou() { static::whoami(); } } class A extends
Base { public static function test() { Base::whoareyou(); self::whoareyou();
parent::whoareyou();

PrepAway - Latest Free Exam Questions & Answers

A.
:test();

B.
Base B A A B

C.
Base B B A B

D.
:whoareyou(); static::whoareyou(); } public static function whoami() { echo “A “; } } class B
extends A { public static function whoami() { echo “B “; } }

E.
Base A Base A B

F.
B B B B B

One Comment on “What is the output of the following code?

  1. peter says:

    The code is like this:

    class Base
    {
    protected static function whoami()
    {
    echo “Base “; }

    public static function whoareyou()
    {
    static::whoami();
    }
    }
    class A extends Base
    {
    public static function test()
    {
    Base::whoareyou();
    self::whoareyou();
    parent::whoareyou();
    A::whoareyou();
    static::whoareyou();
    }
    public static function whoami() {
    echo “A “;
    }
    }
    class B extends A {
    public static function whoami() {
    echo “B “;
    }
    }
    B::test();

    // And the answer is Base B B A B




    13



    0

Leave a Reply

Your email address will not be published. Required fields are marked *