Question:What is the output of the following script?

<?php

class ClassOne {
protected $a = 10;

public function changeValue($b) {
$this->a = $b;
}
}

class ClassTwo extends ClassOne {

protected $b = 10;

public function changeValue($b) {
$this->b = 10;
parent::changeValue($this->a + $this->b);
}

public function displayValues() {
print "a: {$this->a}, b: {$this->b}\n";
}
}

$obj = new ClassTwo();

$obj->changeValue(20);
$obj->changeValue(10);

$obj->displayValues();

?>
 

A  

B  

C  

D  

E a: 10, b: 10 

+ Answer
+ Report
Total Preview: 793

Copyright © 2024. Powered by Intellect Software Ltd