OOP (course 3): Inheritance, Abstract Classes, Interfaces and other amazing things
Calling Parent Class Methods
  Start your All-Access Pass to unlock this challenge
Buy Access Login

Challenge 1 / 2

Check out the following code:

class Ship
{
    private $weaponsCount = 5;

    public function getWeaponsCount()
    {
        return $this->weaponsCount;
    }
}

class RebelShip extends Ship
{
    public function getWeaponsCount()
    {
        return parent::getWeaponsCount() + 2;
    }
}

$rebelShip = new RebelShip();
print $rebelShip->getWeaponsCount();

How many weapons will the getWeaponsCount() call return for the $rebelShip?

Skip challenges and go to theNext Chapter

Turn Challenges Off?

All further challenges will be skipped automatically.
You can re-enable challenges at any time on this page or from your account page.