nerdexam
Zend

200-550 · Question #83

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…

The correct answer is B. Use B::hello() instead of A 's version using B::hello insteadof A. See the full explanation below for the reasoning.

Question

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"; } }

Options

  • ARename the A::hello() method to a different name using A::hello as helloA;
  • BUse B::hello() instead of A 's version using B::hello insteadof A
  • CUse B::hello() instead of A 's version using use B::hello
  • DRename the A::hello() method to a different name using A::hello renameto helloA;
  • ENone of the above (both can be used directly)

How the community answered

(26 responses)
  • A
    4% (1)
  • B
    69% (18)
  • C
    4% (1)
  • D
    15% (4)
  • E
    8% (2)

Community Discussion

No community discussion yet for this question.

Full 200-550 Practice