Sail E0 Webinar

MCQs

Total Questions : 30 | Page 1 of 3 pages
Question 1. PHP recognizes constructors by the name.
  1.    classname()
  2.    _construct()
  3.    function _construct()
  4.    function __construct()
 Discuss Question
Answer: Option D. -> function __construct()


A double underscore followed by the construct keyword. Its syntax is function __construct ([ argument1, argument2,.....]) { Class Initialization code }


Question 2. Which method scope prevents a method from being overridden by a subclass?
  1.    Abstract
  2.    Protected
  3.    Final
  4.    Static
 Discuss Question
Answer: Option C. -> Final


Final


Question 3. Which of the following statements is/are true about Constructors in PHP?(i) PHP 4 introduced class constructors.(ii) Constructors can accept parameters.(iii) Constructors can call class methods or other functions(iv) Class constructors can call on other constructors.
  1.    (ii) and (iii)
  2.    All of the mentioned
  3.    None of the mentioned
  4.    (ii), (iii) and (iv)
 Discuss Question
Answer: Option B. -> All of the mentioned


All of the mentioned


Question 4. Which one of the following functions is used to determine whether a class exists?
  1.    exist()
  2.    exist_class()
  3.    class_exist()
  4.    __exist()
 Discuss Question
Answer: Option C. -> class_exist()


The class_exist() function returns true or false according to whether the class exists within the currently executing script content.


Question 5. Which version of PHP introduced the instanceof keyword?
  1.    PHP 4
  2.    PHP 5
  3.    PHP 5.3
  4.    PHP 6
 Discuss Question
Answer: Option B. -> PHP 5


Using instanceof keyword we can determine whether an object is an instance of a class. $manager = new Employee() ¦ if ($manager instanceof Employee) echo "True;


Question 6. Which one of the following functions is used to determine object type?
  1.    obj_type()
  2.    type()
  3.    is_a()
  4.    is_obj()
 Discuss Question
Answer: Option C. -> is_a()


The is_a() function returns true if object belongs to a class type or if it belongs to a class that is a child of that class. Or else false is returned.


Question 7. Which keyword is used to refer to properties or methods within the class itself?
  1.    private
  2.    public
  3.    protected
  4.    $this
 Discuss Question
Answer: Option D. -> $this


$this


Question 8. In the PHP code given below, what is/are the properties?
< ?php
class Example
{
public $name;
function Sample()
{
echo "This is an example";
}
}
?>
  1.    echo This is an example";
  2.    public $name;
  3.    class Example
  4.    function sample()
 Discuss Question
Answer: Option B. -> public $name;


Yes they are nothing but variables.


Question 9. Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?
  1.    protected
  2.    final
  3.    static
  4.    private
 Discuss Question
Answer: Option C. -> static


static


Question 10. Which one of the following keyword is used to inherit our subclass into a superclass?
  1.    extends
  2.    implements
  3.    inherit
  4.    include
 Discuss Question
Answer: Option A. -> extends


extends


Latest Videos

Latest Test Papers