class Dog extends Animal { } In PHP, the extends keyword is used to implement inheritance, where the child class (Dog) inherits from the parent class (Animal).
2.
Which access modifier in PHP restricts access to class members?
class Example { private $variable; } The private access modifier restricts access to class members so that they can only be accessed from within the same class.
Encapsulation in PHP refers to hiding the implementation details of data and methods within a class, exposing only the necessary interfaces to interact with the class.
Polymorphism in PHP is achieved through method overriding, where a child class can provide its own implementation of a method defined in its parent class.
5.
Which keyword is used to access parent class properties in PHP?
Encapsulation in OOP is primarily used to hide the implementation details of a class, allowing for better maintainability and preventing unauthorized access.
Polymorphism allows a method to have multiple implementations, meaning that methods can be overridden in child classes with different behaviors while retaining the same method signature.