Given the following code, how can we use both traits A and B in the same class? (select all that apply)trait A {public function hello() {return "hello";}public function world() {return "world"; }}trait B {public function hello() {return "Hello";}public function person($name) {return ":$name";}}
Answer(s): B
In the following code, which line should be changed so it outputs the number 2:class A {protected $x = array(); /* A */public function getX() { /* B */return $this->x; /* C */}}$a = new A(); /* D */array_push($a->getX(), "one");array_push($a->getX(), "two");echo count($a->getX());
Answer(s): C
What is the output of the following code?class A {public $a = 1;public function __construct($a) { $this->a = $a; }public function mul() {return function($x) {return $this->a*$x;};}}$a = new A(2);$a->mul = function($x) {return $x*$x;};$m = $a->mul();echo $m(3);
CORRECT TEXTWhat is the output of the following code?class Number {private $v = 0;public function __construct($v) { $this->v = $v; }public function mul() {return function ($x) { return $this->v * $x; };}}$one = new Number(1);$two = new Number(2);$double = $two->mul()->bindTo($one);echo $double(5);
Answer(s): A
What is the output of the following code?class Number {private $v;private static $sv = 10;public function __construct($v) { $this->v = $v; }public function mul() {return static function ($x) {return isset($this) ? $this->v*$x : self::$sv*$x;};}}$one = new Number(1);$two = new Number(2);$double = $two->mul();$x = Closure::bind($double, null, 'Number');echo $x(5);
Post your Comments and Discuss Zend 200-550 exam prep with other Community members:
Our website is free, but we have to fight against AI bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the 200-550 content, but please register or login to continue.