Php Objective Questions with Answers for written test exams 6

Question 6
What will the following script output?


error_reporting(E_ALL);

class a

{

var $c;

function a()

{

$this->c = 10;

}

}

class b extends a

{

function print_a()

{

echo $this->c;

}

}

$b = new b;

$b->print_a();

?>

A. Nothing

B. An error because b does not have a constructor

C. 10

D. NULL

E. False
Answers 6


Answer C is correct. Because the class b does not have a constructor, the constructor

of its parent class is executed instead.This results in the value 10 being assigned

to the $c member property

  







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---