ExamVeda
Login
Home
41
Which keyword must be added before $first variable on the third line of the above question to make $second and $first as distinct objects in PHP 5?
Discuss
Answer & Solution
Answer: Option B
Solution:
Clone operates on an object instance, producing a by-value copy.
42
What will be the output of the following PHP code
class Person 
{
    function getName() { return "Bob"; }
    function getAge() { return 44; }
    function __toString() {
        $desc = $this->getName();
        $desc .= " (age ".$this->getAge().")";
        return $desc;
    }
}
$person = new Person();
print $person;
Discuss
Answer & Solution
Answer: Option C
Solution:
By implementing a __toString() method, you can control how your objects represent themselves when printed. The method is invoked automatically when your object is passed to print or echo, and its return value is substituted.
43
______clone() is run on the _______ object.
Discuss
Answer & Solution
Answer: Option D
Solution:
__clone() is run on the copied object and not the original.
44
Which method is invoked when an undefined property is accessed ?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
45
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
    }
}
Discuss
Answer & Solution
Answer: Option D
Solution:
A final class cannot be subclassed. Less drastically, a final method cannot be overridden.
46
The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
47
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?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
48
The practice of creating objects based on predefined classes is often referred to as.
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
49
Which one of the following property scopes is not supported by PHP?
Discuss
Answer & Solution
Answer: Option A
Solution:
PHP supports five class property scopes: public, private, protected, final and static.
50
Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board