Vidyalelo
PHP · all questions

Object Oriented Concept
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

141

Questions

3/8

Page

Pick an option on a question to see the right answer and solution.

Which keyword must be added before second and $first as distinct objects in PHP 5?

Select an option to see the answer and solution.

What will be the output of the following PHP code
class Person 
{
    function getName() { return "Bob"; }
    function getAge() { return 44; }
    function __toString() {
        this->getName();
        this->getAge().")";
        return $desc;
    }
}
$person = new Person();
print $person;

Select an option to see the answer and solution.

______clone() is run on the _______ object.

Select an option to see the answer and solution.

Which method is invoked when an undefined property is accessed ?

Select an option to see the answer and solution.

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
    }
}

Select an option to see the answer and solution.

The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________

Select an option to see the answer and solution.

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?

Select an option to see the answer and solution.

The practice of creating objects based on predefined classes is often referred to as.

Select an option to see the answer and solution.

Which one of the following property scopes is not supported by PHP?

Select an option to see the answer and solution.

Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?

Select an option to see the answer and solution.

Which one of the following is the right way to define a constant?

Select an option to see the answer and solution.

Which one of the following is the right way to call a class constant, given that the class is mathFunction?

Select an option to see the answer and solution.

Which one of the following is the right way to invoke a method?

Select an option to see the answer and solution.

Which of the following is/are the right way to declare a method?
1. function functionName() { function body }
2. scope function functionName() { function body }
3. method methodName() { method body }
4. scope method methodName() { method body }

Select an option to see the answer and solution.

Which of the following method scopes is/are not supported by PHP?
1. private
2. final
3. static
4 abstract

Select an option to see the answer and solution.

Which method scope prevents a method from being overridden by a subclass?

Select an option to see the answer and solution.

Which of the following statements is/are true about Constructors in PHP?
1. PHP 4 introduced class constructors.
2. Constructors can accept parameters.
3. Constructors can call class methods or other functions.
4. Class constructors can call on other constructors.

Select an option to see the answer and solution.

PHP recognizes constructors by the name_________

Select an option to see the answer and solution.

Which version of PHP introduced the instanceof keyword?

Select an option to see the answer and solution.

Which one of the following functions is used to determine whether a class exists?

Select an option to see the answer and solution.