PHP QUESTIONS AND ANSWERS
Write basic concepts of OOP - Answers -Abstraction.
Encapsulation.
Inheritance.
Polymorphism.
What is a class - Answers -A class is simply a representation of a type of object. It is
the blueprint/ plan/ template that describes the details of an object.
What is an object - Answers -An object for constructor as an instance of a class, and it
has its own state, behavior, and identity
Encapsulation - Answers -exposes only necessary information to the calling functions
Encapsulation is an attribute of an object, and it contains all data which is hidden. That
hidden data can be restricted to the members of that class.
Levels are Public, Protected, Private, Internal and Protected Internal.
Polymorphism - Answers -It's simply the idea that one object can take on many forms.
So in PHP OOP one class "cars" may have two classes that extend it, for example a
"Honda" class and a "BMW" class.
What is Inheritance - Answers -Inheritance is a concept where one class shares the
structure and behavior defined in another class. If inheritance applied on one class is
called Single Inheritance, and if it depends on multiple classes, then it is called multiple
Inheritance.
In a PHP class what are the three visibility keywords of a property or method? -
Answers -public, private and protected.
The default is public.
Public Property - Answers -Any class may instantiate the class and call the method or
property.
Protected Property - Answers -Only the class itself or inherited (children) classes may
call a method or property
Private Property - Answers -Only the class itself may call a method or property.
What is static and dynamic binding - Answers -Binding is nothing but the association of
a name with the class. Static binding is a binding in which name can be associated with
the class during compilation time, and it is also called as early Binding.
Write basic concepts of OOP - Answers -Abstraction.
Encapsulation.
Inheritance.
Polymorphism.
What is a class - Answers -A class is simply a representation of a type of object. It is
the blueprint/ plan/ template that describes the details of an object.
What is an object - Answers -An object for constructor as an instance of a class, and it
has its own state, behavior, and identity
Encapsulation - Answers -exposes only necessary information to the calling functions
Encapsulation is an attribute of an object, and it contains all data which is hidden. That
hidden data can be restricted to the members of that class.
Levels are Public, Protected, Private, Internal and Protected Internal.
Polymorphism - Answers -It's simply the idea that one object can take on many forms.
So in PHP OOP one class "cars" may have two classes that extend it, for example a
"Honda" class and a "BMW" class.
What is Inheritance - Answers -Inheritance is a concept where one class shares the
structure and behavior defined in another class. If inheritance applied on one class is
called Single Inheritance, and if it depends on multiple classes, then it is called multiple
Inheritance.
In a PHP class what are the three visibility keywords of a property or method? -
Answers -public, private and protected.
The default is public.
Public Property - Answers -Any class may instantiate the class and call the method or
property.
Protected Property - Answers -Only the class itself or inherited (children) classes may
call a method or property
Private Property - Answers -Only the class itself may call a method or property.
What is static and dynamic binding - Answers -Binding is nothing but the association of
a name with the class. Static binding is a binding in which name can be associated with
the class during compilation time, and it is also called as early Binding.