PHP Objects MCQs
PHP Objects MCQs : This section focuses on "Objects" in PHP. These Multiple Choice Questions (mcq) should be practiced to improve the PHP skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. Objects are also known as ______.
View Answer
2. Object are created using ____ keyword?
View Answer
3. A member function typically accesses members of _____ object only
View Answer
4. Constructor is also called ____ function
View Answer
5. Which of the following is the output of the below code?
<?php
class letsfindcourse
{
public $lfc_name = "letsfindcourse";
public function __construct($lfc_name)
{
$this->lfc_name = $lfc_name;
}
}
$lfc = new letsfindcourse("letsfindcourse");
echo $lfc->lfc_name;
?>
View Answer
6. Which of the following is the output of the below code?
<?php
class lfc {
var $mcq_type;
function setmcq_type($par){
$this->mcq_type = $par;
}
function getmcq_type(){
echo $this->mcq_type."<br>";
}
}
$obj = new lfc;
$obj->setmcq_type("Objects Mcq");
$obj->getmcq_type();
?>
View Answer
7. PHP recognizes constructors by the name.
View Answer
8. Which one of the following functions is used to determine object type?
View Answer
9. Which one of the following can be used to instantiate an object in PHP assuming class name to be LFC?
View Answer
10. In the PHP code given below, what is/are the properties?
<?php
class letsfindcourse
{
public $name;
function lfc()
{
echo "This is an Object Mcq";
}
}
?>
View Answer
Also check :
Discussion