Object Oriented Concept - Study Mode

[#121] Prior to which version of PHP did constructors took the name of the enclosing class.
Correct Answer

(B) PHP 5

Explanation

Solution: The new unified constructors use the name __construct(). Using the old syntax, a call to a parent constructor would tie you to that particular class: parent::ShopProduct()

[#122] _________ are used in class diagrams to describe the way in which specific elements should be used.
Correct Answer

(B) Constraints

Explanation

Solution: The {abstract} syntax is an example of a constraint. There is no special structure for the text between the braces
it should simply provide a short clarification of any conditions that may apply to the element.

[#123] 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
Correct Answer

(C) BOB (age 44)

Explanation

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.

[#124] Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
Correct Answer

(C) $obj = new foo ()

[#125] Which keyword can be used to fix the above error?
Correct Answer

(C) use

Explanation

Solution: Use keyword allows you to alias other namespaces within the current namespace. Example – namespace main
use comgetinstanceutil
utilDebug::helloWorld()