What is the difference between the keyword ‘Private’ and ‘Final’?

Having a confusion between Private and Final in PHP.

For example I have 3 classes:

  1. Class A (parent class)
  2. Class B (child class)
  3. Class C (other class)

What I understand:

  • A: Public variables and methods are accessible to the class A, class B and class C
  • B: Private variables and methods are only accessible to the class A.
  • C: Protected variables and methods are only accessible to the class A and class B
  • D: Final methods are only accessible to the class A not to class B.

My Question is:

After using private we can achieve functionality like final then why we use final?

I am asking this question only for my clarification for myself.


Source: oop

Leave a Reply