PrepAway - Latest Free Exam Questions & Answers

Given the following code, what will the output be:

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

PrepAway - Latest Free Exam Questions & Answers

A.
int(3)

B.
NULL

C.
Notice: Undefined property MyClass::$abc

D.
Fatal error: Access to private variable MyTrait::$abc from context MyClass

E.
int(2)


Leave a Reply

Your email address will not be published. Required fields are marked *