nerdexam
Zend

200-710 · Question #110

What is the output of the following code? ``php class Number { private $v = 0; public function __construct($v) { $this->v = $v; } public function mul() { return function ($x) { return $this->v * $x; }

The correct answer is A. 5. See the full explanation below for the reasoning.

Question

What 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);

Options

  • A5
  • BC.
  • C
  • D

How the community answered

(35 responses)
  • A
    71% (25)
  • B
    6% (2)
  • C
    9% (3)
  • D
    14% (5)

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice