Q: In the PHP code given below, what is/are the properties?
< ?php
class Example
{
public $name;
function Sample()
{
echo "This is an example";
}
}
?>
A.echo
B. public $name;
C.class Example
D. function sample()
Correct Option: BExplanation: Yes they are nothing but variables.
Q: If your object must inherit behavior from a number of sources you must use a/an
A.Interface
B.Object
C.abstract class
D.static class
Correct Option: AExplanation: Interface
Q: Which one of the following functions is used to determine object type?
A.obj_type()
B.type()
C.is_a()
D.is_obj()
Correct Option: CExplanation: The is_a() function returns true if object belongs to a class type or if it belongs to a class that is a child of that class. Or else false is returned.
Q: The practice of separating the user from the true inner workings of an application through well-known interfaces is known as..
A.Polymorphism
B.Inheritance
C.Encapsulation
D.Abstraction
Correct Option: CExplanation: Encapsulation
Q: Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
A.$obj = new $foo;
B.$obj = new foo;
C.$obj = new foo ();
D.obj = new foo ();
Correct Option: CExplanation: $obj = new foo ();
Q: Which of the following advanced OOP features is/are not supported by PHP?
(i) Method overloading
(ii) Multiple Inheritance
(iii) Namespaces
(iv) Object Cloning
A.All of the mentioned
B.All of the mentioned
C. (i) and (ii)
D.(iii) and (iv)
Correct Option: CExplanation: The advanced OOP features are: Object cloning, Inheritance, Interfaces, Abstract classes, and Namespaces.
Q: The class from which the child class inherits is called.
(i) Child class
(ii) Parent class
(iii) Super class
(iv) Base class
A.Only (i)
B.(ii), (iii) and (iv)
C.Only (iii)
D.(ii) and (iv)
Correct Option: DExplanation: (ii) and (iv)
Q: Which of the following is/are true for an abstract class?
(i) A class is declared abstract by prefacing the definition with the word abstract.
(ii) A class is declare abstract by using the keyword implements.
(iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class.
(iv) Attempting to instantiate an abstract class results in an error.
A.Only (ii)
B.All of the mentioned
C. (ii) and (iv)
Correct Option: AExplanation: Only (ii)
Q: Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?
A.protected
B. final
C.static
D. private
Correct Option: CExplanation: static
Q: Which one of the following is the right way to define a constant?
A.constant PI =
B.const $PI =
C. constant PI =
D. const PI =
Correct Option: DExplanation: Class constants are created like: const NAME = ‘VALUE’;