PHP-PHP Mcq Basics of Object/Oriented PHP Sample Test,Sample questions

Question:
 If one intends to create a model that will be assumed by a number of closely related objects, which class must be used?

1.Normal class

2.Static class

3.Abstract class

4.Interface


Question:
 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


Question:
 Which version of PHP introduced the instanceof keyword?

1.PHP 4

2.PHP 5

3.PHP 5.3

4.PHP 6


Question:
. In the following PHP code, 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()


Question:
. Which of the following method scopes is/are not supported by PHP?

i) private
ii) friendly
iii) static
iv) abstract

1.Only ii)

2.Only iv)

3.ii) and iv)

4.Only i)


Question:
PHP recognizes constructors by the name _________

1.classname()

2._construct()

3.function _construct()

4.function __construct()


Question:
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


Question:
Which feature allows us to call more than one method or function of the class in single instruction?

1.Typecasting

2.Method Including

3.Method adding

4.Method chaining


Question:
Which keyword is used to refer to properties or methods within the class itself?

1.private

2.public

3.protected

4.$this


Question:
Which magic method is used to implement overloading in PHP?

1.__call

2.__invoke

3.__wakeup

4.__unset


Question:
Which method is used to tweak an object’s cloning behavior?

1.clone()

2.__clone()

3._clone

4. object_clone()


Question:
Which of the following advanced OOP features is/are not supported by PHP?

1.Method overloading

2.Multiple Inheritance

3.Namespaces

4.Object Cloning


Question:
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)


Question:
Which of the following is/are true for an abstract class?
i) Abstract classes in PHP are declared with the help of abstract keyword.
ii) A class is declare abstract by using the keyword implements.
iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class.
iv) Attempting to instantiate an abstract class results in an error.

1.Only i)

2.Only iii)

3.ii) and iv)

4. ii), iii) and iv)


Question:
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)

2. ii) and iii)

3.i), ii), iii) and iv)

4. ii), iii) and iv)


Question:
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


Question:
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 ();


Question:
Which one of the following functions is used to determine object type?

1.obj_type()

2. type()

3.is_a()

4.is_obj()


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

1.exist()

2.exist_class()

3.class_exist()

4.__exist()


Question:
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;


Question:
Which one of the following is the right way to clone an object?

1._clone(targetObject);

2.destinationObject = clone targetObject;

3.destinationObject = _clone(targetObject);

4.destinationObject = clone(targetObject);


Question:
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’;


Question:
Which one of the following keyword is used to inherit our subclass into a superclass?

1.extends

2.implements

3.inherit

4.include


More MCQS

  1. PHP Mcq Set 1
  2. PHP Mcq Set 2
  3. PHP Mcq Set 3
  4. PHP Mcq Set 4
  5. Current affairs mcq php
  6. Current affairs mcq php set 2
  7. Current affairs mcq php set 3
  8. PHP MCQ
  9. PHP MCQ Basics
  10. PHP Mcq Functions
  11. PHP Mcq Arrays
  12. PHP Mcq Basics of Object-Oriented PHP
  13. PHP Mcq Error Handling
  14. PHP Basics Mcq Questions
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!