Zend
200-550 · Question #82
200-550 Question #82: Real Exam Question with Answer & Explanation
Sign in or unlock 200-550 to reveal the answer and full explanation for question #82. The question stem and answer options stay visible for context.
Question
Given the following code, what will the output be: trait MyTrait { private $abc = 1; public function increment() { $this->abc++; } public function getValue() { return $this->abc; } } class MyClass { use MyTrait; public function incrementBy2() { $this->increment(); $this->abc++; } } $c = new MyClass; $c->incrementBy2(); var_dump($c->getValue());
Options
- AFatal error: Access to private variable MyTrait::$abc from context MyClass
- BNotice: Undefined property MyClass::$abc
- Cint(2)
- Dint(3)
- ENULL
Unlock 200-550 to see the answer
You've previewed enough free 200-550 questions. Unlock 200-550 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.