Question from the Object Oriented Programming test

How to call a method from a parent class in a child class in PHP

Expert

What will the following pseudo-code display?

class A 
{
    public function foobar() {
       echo this->foo();
       echo this->bar();
    }

    private function foo() {
       return "A::foo\\n";
    }

    public function bar() {
       echo "A::bar\\n";
    }
}

class B extends A 
{
    private function foo() {
       return "B::foo\\n";
    }

    public function bar() {
       echo "B::bar\\n";
    }
}

var toto = new B();
toto->foobar();
Author: Eric HostaleryStatus: PublishedQuestion passed 1377 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!