MCQs > IT & Programming > PHP 5 > Output of the following PHP 7.1 code snippet? - abstract class A_Class { abstract protected function name_P($name); } class Example extends A_Class { public function Name_P($name, $separator = '.') { if ($name == 'Mango') { $product = 'Fruit'; } elseif ($name == 'Carrot') { $product = 'Vegitable'; } else { $product =''; } return '{$name}{$separator} {$product}'; } } $class = new Example; echo $class->Name_P('Mango'), '\n'; echo $class->Name_P('Carrot'), '\n'; ?>

PHP 5 MCQs

What will be the output of the following PHP 7.1 code snippet?

-

abstract class A_Class

{

abstract protected function name_P($name);

}

class Example extends A_Class

{

public function Name_P($name, $separator = ".") {

if ($name == "Mango") {

$product = "Fruit";

} elseif ($name == "Carrot") {

$product = "Vegitable";

} else {

$product ="";

}

return "{$name}{$separator} {$product}";

}

}

$class = new Example;

echo $class->Name_P("Mango"), "\n";

echo $class->Name_P("Carrot"), "\n";

?>

Answer

Correct Answer:

-Mango. Fruit

Carrot. Vegitable


Explanation:

Note: This Question is unanswered, help us to find answer for this one

PHP 5 Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

More PHP 5 MCQ Questions

search

PHP 5 Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it