Explain the difference between a final class and an abstract class, and when would you want to prevent a class from being inherited?

Last updated 15 June 2026

  • An abstract class is an incomplete base that cannot be instantiated and must be extended. A final class is complete, and extending it is a fatal error.

  • Individual methods can also be marked final to block overriding while still allowing subclassing.

  • Prevent inheritance for value objects and immutable types, and for security- or correctness-critical logic. It also signals composition over extension.

  • https://www.monster.com.vn/career-advice/top-30-php-oops-interview-questions-and-answers/
  • https://www.scribd.com/document/886677949/OOPS-Interview-Questions-and-Answers-2025-PrepInsta
  • https://www.freecodecamp.org/news/java-interview-prep-handbook/
All PHP interview questions