Which code snippet demonstrates encapsulation?

  • [ ]
    class Cow extends Animal {
    private $milk;
    }
  • [ ]
    class Cow {
    public $milk;
    }
    $daisy = new Cow();
    $daisy->milk = “creamy”;
  • [ ]
    class Cow {
    public $milk;
    function getMilk() {`
    return $this->milk;
    }
    }
  • [x]
    class Cow {
    private $milk;
    public function getMilk() {
    return $this->milk;
    }
    }
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend