Jump to content

Simple OOP concept here (final vs. private)?


extrovertive

Recommended Posts

I know a final method (i.e. final public function foo(){}) prevents a child class from overriding that method.

 

But can a private method be override in a child class? If so, what's difference does it make between a protected method? What's the difference between making a method final and a method private? Examples?

private method can not be called from child classes, final can (as long as it is protected or public)

 

In other words: public, protected, private - tell who can call the method

final - tells that method can not be overriden

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.