OOP (course 4): Static methods, Namespaces, Exceptions & Traits! Woh!
Static or Non-Static Methods?
  Unlock this challenge
Login Register

Challenge 1 / 2

We're building a new class of planets that always have the same radius. We're in a heated (geeky) debate over whether or not to make a method static. Here are the two options:

// OPTION 1
class StaticallySizedPlanet
{
    public function getRadius()
    {
        return 250;
    }
}
// OPTION 2
class StaticallySizedPlanet
{
    public static function getRadius()
    {
        return 250;
    }
}

Which would you recommend?

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.