Question: Study the classes below: class A { protected $name, $id; private static $number = 1 ; public function _ _ construct ( $na ) {

Study the classes below:
class A{
protected $name, $id;
private static $number =1;
public function __construct($na){
$this->name = $na;
$this->id = self::$number;
self::$number++;
}
public function setName($na){
$this->name = $na;
}
public function getName(){
return $this->name;
}
public function getID(){
return $this->id;
}
public function toString(){
return "$this->name,$this->id";
}
}
class B extends A{
protected $type;
public function __construct($na, $ty){
$this->type = $ty;
parent::__construct($na);
}
public function setType($ty){
$this->type = $ty;
}
public function getType(){
return $type;
}
public function toString(){
return parent::toString().",".$this->type;
}
}
Which one of the following options is correct for the code above?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!