Sail E0 Webinar

MCQs

Total Questions : 30 | Page 2 of 3 pages
Question 11. Which one of the following is the right way to define a constant?
  1.    constant PI = 3.1415?;
  2.    const $PI = 3.1415?;
  3.    constant PI = '3.1415';
  4.    const PI = '3.1415';
 Discuss Question
Answer: Option D. -> const PI = '3.1415';


Class constants are created like: const NAME = 'VALUE';


Question 12. Which of the following method scopes is/are not supported by PHP?(i) private(ii) final(iii) static(iv) abstract
  1.    Only (ii)
  2.    Only (iv)
  3.    (ii) and (iv)
 Discuss Question
Answer: Option C. -> (ii) and (iv)


PHP supports six method scopes: public, private, final, static, protected and abstract.


Question 13. Which one of the following is the right way to invoke a method?
  1.    $object->methodName();
  2.    object->methodName();
  3.    object::methodName();
  4.    $object::methodName();
 Discuss Question
Answer: Option A. -> $object->methodName();


$object->methodName();


Question 14. Which of the following is/are the right way to declare a method?(i) function functionName() { function body }(ii) scope function functionName() { function body }(iii) method methodName() { method body }(iv) scope method methodName() { method body }
  1.    Only (ii)
  2.    Only (iv)
  3.    (i) and (ii)
  4.    (iii) and (iv)
 Discuss Question
Answer: Option C. -> (i) and (ii)


In case of public methods, you can forgo explicitly declaring the scope and just declare the method like you would a function.


Question 15. Which one of the following is the right way to call a class constant, given that the class is mathFunction?
  1.    echo PI;
  2.    echo mathFunction->PI;
  3.    echo mathFunction::PI;
  4.    echo mathFunction=PI;
 Discuss Question
Answer: Option C. -> echo mathFunction::PI;


echo mathFunction::PI;


Question 16. The practice of separating the user from the true inner workings of an application through well-known interfaces is known as..
  1.    Polymorphism
  2.    Inheritance
  3.    Encapsulation
  4.    Abstraction
 Discuss Question
Answer: Option C. -> Encapsulation


Encapsulation


Question 17. The practice of creating objects based on predefined classes is often referred to as..
  1.    class creation
  2.    object creation
  3.    object instantiation
  4.    class instantiation
 Discuss Question
Answer: Option D. -> class instantiation


class instantiation


Question 18. hich of the following term originates from the Greek language that means "having multiple forms, defines OOP's ability to redefine, a class's characteristic
  1.    Abstraction
  2.    Polymorphism
  3.    Inheritance
  4.    Differential
 Discuss Question
Answer: Option B. -> Polymorphism


Polymorphism


Question 19. Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
  1.    $obj = new $foo;
  2.    b) $obj = new foo;
  3.    $obj = new foo ();
  4.    obj = new foo ();
 Discuss Question
Answer: Option C. -> $obj = new foo ();


$obj = new foo ();


Question 20. Which one of the following property scopes is not supported by PHP?
  1.    friendly
  2.    final
  3.    public
  4.    static
 Discuss Question
Answer: Option A. -> friendly


PHP supports five class property scopes: public, private, protected, final and static.


Latest Videos

Latest Test Papers