PrepAway - Latest Free Exam Questions & Answers

In the following code, which line should be changed so it outputs the number 2:

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

PrepAway - Latest Free Exam Questions & Answers

A.
No changes needed, the code would output 2 as is

B.
Line A, to: protected &$x = array();

C.
Line B, to: public function &getX() {

D.
Line C, to: return &$this->x;

E.
Line D, to: $a =& new A();

One Comment on “In the following code, which line should be changed so it outputs the number 2:

  1. Max says:

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




    0



    0

Leave a Reply

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