Which keyword must be added before f i r s t v a r iab l eo n t h e t hi r d l in eo f t h e ab o v e q u es t i o n t o mak e second and $first as distinct objects in PHP 5?
A. copy
B. clone
C. cut
D. Can’t add any word to make them distinct
Select an option to see the answer and solution.
What will be the output of the following PHP code
class Person
{
function getName() { return "Bob" ; }
function getAge() { return 44 ; }
function __toString() {
d esc < s p an c l a ss = " p − b l u e " >= this->getName();
d esc . < s p an c l a ss = " p − b l u e " >=< / s p an > " ( < s p an c l a ss = " p − r e d " > a g e < / s p an > ". < s p an c l a ss = " p − b l u e " > this->getAge() .")";
return $desc;
}
}
$person = new Person() ;
print $person; A. Object Not Found
B. PHP Catchable fatal error
C. BOB (age 44)
D. BOB
Select an option to see the answer and solution.
______clone() is run on the _______ object.
A. original
B. pseudo
C. external
D. copied
Select an option to see the answer and solution.
Which method is invoked when an undefined property is accessed ?
A. __get()
B. __isset()
C. __unset()
D. __undefined()
Select an option to see the answer and solution.
What will be the output of the following PHP code?
class Checkout
{
final function totalize()
{
// calculate bill
}
}
class IllegalCheckout extends Checkout
{
final function totalize()
{
// change bill calculation
}
} A. PHP Fatal error: Class IllegalCheckout may not inherit from final class
B. Value of the bill calculated
C. PHP Fatal error: Cannot find object
D. PHP Fatal error: Cannot override final method
Select an option to see the answer and solution.
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
Select an option to see the answer and solution.
Which of the following term originates from the Greek language that means “having multiple forms,” defines OOP’s ability to redefine, a class’s characteristics?
A. Abstraction
B. Polymorphism
C. Inheritance
D. Differential
Select an option to see the answer and solution.
The practice of creating objects based on predefined classes is often referred to as.
A. class creation
B. object creation
C. object instantiation
D. class instantiation
Select an option to see the answer and solution.
Which one of the following property scopes is not supported by PHP?
A. friendly
B. final
C. public
D. static
Select an option to see the answer and solution.
Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
A. o bj = n e w foo;
B. $obj = new foo;
C. $obj = new foo ();
D. obj = new foo ();
Select an option to see the answer and solution.
Which one of the following is the right way to define a constant?
A. constant PI = “3.1415”;
B. const $PI = “3.1415”;
C. constant PI = ‘3.1415’;
D. const PI = ‘3.1415’;
Select an option to see the answer and solution.
Which one of the following is the right way to call a class constant, given that the class is mathFunction?
A. echo PI;
B. echo mathFunction->PI;
C. echo mathFunction::PI;
D. echo mathFunction=PI;
Select an option to see the answer and solution.
Which one of the following is the right way to invoke a method?
A. $object->methodName();
B. object->methodName();
C. object::methodName();
D. $object::methodName();
Select an option to see the answer and solution.
Which of the following is/are the right way to declare a method?
1. function functionName() { function body }
2. scope function functionName() { function body }
3. method methodName() { method body }
4. scope method methodName() { method body }
A. Only 2
B. Only 4
C. 1 and 2
D. 3 and 4
Select an option to see the answer and solution.
Which of the following method scopes is/are not supported by PHP?
1. private
2. final
3. static
4 abstract
A. Only 2
B. Only 4
C. 2 and 4
D. None of the mentioned
Select an option to see the answer and solution.
Which method scope prevents a method from being overridden by a subclass?
A. Abstract
B. Protected
C. Final
D. Static
Select an option to see the answer and solution.
Which of the following statements is/are true about Constructors in PHP?
1. PHP 4 introduced class constructors.
2. Constructors can accept parameters.
3. Constructors can call class methods or other functions.
4. Class constructors can call on other constructors.
A. 2 and 4
B. All of the mentioned
C. None of the mentioned
D. 2, 3 and 4
Select an option to see the answer and solution.
PHP recognizes constructors by the name_________
A. classname()
B. _construct()
C. function _construct()
D. function __construct()
Select an option to see the answer and solution.
Which version of PHP introduced the instanceof keyword?
A. PHP 4
B. PHP 5
C. PHP 5.3
D. PHP 6
Select an option to see the answer and solution.
Which one of the following functions is used to determine whether a class exists?
A. exist()
B. exist_class()
C. class_exist()
D. __exist()
Select an option to see the answer and solution.