Sail E0 Webinar

MCQs

Total Questions : 147 | Page 5 of 15 pages
Question 41. Which keyword must be added before $first variable on the third line of the above question to make $second and $first as distinct objects in PHP 5?
  1.    copy
  2.    clone
  3.    cut
  4.    Can’t add any word to make them distinct
 Discuss Question
Answer: Option B. -> clone
Question 42. What will be the output of the following PHP code
class Person
{
function getName() { return "Bob"; }
function getAge() { return 44; }
function __toString() {
$desc = $this->getName();
$desc .= " (age ".$this->getAge().")";
return $desc;
}
}
$person = new Person();
print $person;
  1.    Object Not Found
  2.    PHP Catchable fatal error
  3.    BOB (age 44)
  4.    BOB
 Discuss Question
Answer: Option C. -> BOB (age 44)
Question 43. Which method is invoked when an undefined property is accessed ?
  1.    __get()
  2.    __isset()
  3.    __unset()
  4.    __undefined()
 Discuss Question
Answer: Option A. -> __get()
Question 44. What will be the output of the following PHP code?
class Checkout
{
final function totalize()
{
// calculate bill
}
}
class IllegalCheckout extends Checkout
{
final function totalize()
{
// change bill calculation
}
}
  1.    PHP Fatal error: Class IllegalCheckout may not inherit from final class
  2.    Value of the bill calculated
  3.    PHP Fatal error: Cannot find object
  4.    PHP Fatal error: Cannot override final method
 Discuss Question
Answer: Option D. -> PHP Fatal error: Cannot override final method
Question 45. 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
Question 46. Which of the following term originates from the Greek language that means “having multiple forms,” defines OOP’s ability to redefine, a class’s characteristics?
  1.    Abstraction
  2.    Polymorphism
  3.    Inheritance
  4.    Differential
 Discuss Question
Answer: Option B. -> Polymorphism
Question 47. 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
Question 48. 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
Question 49. 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.    $obj = new foo;
  3.    $obj = new foo ();
  4.    obj = new foo ();
 Discuss Question
Answer: Option C. -> $obj = new foo ();
Question 50. 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’;

Latest Videos

Latest Test Papers