MCQGeeks
0 : 0 : 1
CBSE
JEE
NTSE
NEET
English
UK Quiz
Quiz
Driving Test
Practice
Games
Quiz
php
Quiz 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Q.1
Which function was introduced to help automate the inclusion of class files?
__load()
__preload()
__autoload()
__inload()
Q.2
Which magic method is used to implement overloading in PHP?
__call
__invoke
__wakeup
__unset
Q.3
A package is a set of related _________
Objects
Classes
Programs
Functions
Q.4
Till which version of PHP, developers were forced to name their files in a global context?
PHP 4
PHP 5
PHP 5.2
PHP 5.3
Q.5
Which of the following can you place inside a namespace?
1. classes
2. functions
3. variables
1
2
3
All of the mentioned
Q.6
Which one of the following is the correct way of declaring a namespace?
namespace my;
namespace my();
my namespace;
namespace(my);
Q.7
Which of the following is/are true for an abstract class?
1. A class is declared abstract by prefacing the definition with the word abstract.
2. A class is declare abstract by using the keyword implements.
3. It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class.
4. Attempting to instantiate an abstract class results in an error.
Only 2
All of the mentioned
2 and 4
2, 3 and 4
Q.8
If one intends to create a model that will be assumed by a number of closely related objects, which class must be used?
Normal class
Static class
Abstract class
Interface
Q.9
Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?
protected
final
static
private
Q.10
Which of the following advanced OOP features is/are not supported by PHP?
1. Method overloading
2. Multiple Inheritance
3. Namespaces
4. Object Cloning
All of the mentioned
None of the mentioned
1 and 2
3 and 4
Q.11
If your object must inherit behavior from a number of sources you must use a/an
Interface
Object
Abstract class
Static class
Q.12
Which method is used to tweak an object’s cloning behavior?
clone()
__clone()
_clone
object_clone()
Q.13
Which feature allows us to call more than one method or function of the class in single instruction?
Typecasting
Method Including
Method adding
Method chaining
Q.14
Which version of PHP introduced the advanced concepts of OOP?
PHP 4
PHP 5
PHP 5.3
PHP 6
Q.15
Which one of the following is the right way to clone an object?
_clone(targetObject);
destinationObject = clone targetObject;
destinationObject = _clone(targetObject);
destinationObject = clone(targetObject);
Q.16
The class from which the child class inherits is called.
1. Child class
2. Parent class
3. Super class
4. Base class
Only 1
2, 3 and 4
Only 3
2 and 4
Q.17
Which one of the following functions is used to determine whether a class exists?
exist()
exist_class()
class_exist()
__exist()
Q.18
Which one of the following functions is used to determine object type?
obj_type()
type()
is_a()
is_obj()
Q.19
Which one of the following keyword is used to inherit our subclass into a superclass?
extends
implements
inherit
include
Q.20
In the PHP code given below, what is/are the properties?
<?php
class
Example {
public
$name;
function
Sample
()
{
echo
"This is an example"
; } }
?>
echo “This is an example”;
public $name;
class Example
function sample()
Q.21
Which keyword is used to refer to properties or methods within the class itself?
private
public
protected
$this
Q.22
Which of the following method scopes is/are not supported by PHP?
1. private
2. final
3. static
4 abstract
Only 2
Only 4
2 and 4
None of the mentioned
Q.23
Which method scope prevents a method from being overridden by a subclass?
Abstract
Protected
Final
Static
Q.24
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.
2 and 4
All of the mentioned
None of the mentioned
2, 3 and 4
Q.25
PHP recognizes constructors by the name_________
classname()
_construct()
function _construct()
function __construct()
Q.26
Which version of PHP introduced the instanceof keyword?
PHP 4
PHP 5
PHP 5.3
PHP 6
Q.27
Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
$obj = new $foo;
$obj = new foo;
$obj = new foo ();
obj = new foo ();
Q.28
Which one of the following is the right way to define a constant?
constant PI = “3.1415”;
const $PI = “3.1415”;
constant PI = ‘3.1415’;
const PI = ‘3.1415’;
Q.29
Which one of the following is the right way to call a class constant, given that the class is mathFunction?
echo PI;
echo mathFunction->PI;
echo mathFunction::PI;
echo mathFunction=PI;
Q.30
Which one of the following is the right way to invoke a method?
$object->methodName();
object->methodName();
object::methodName();
$object::methodName();
0 h : 0 m : 1 s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Report Question
×
What's an issue?
Question is wrong
Answer is wrong
Other Reason
Want to elaborate a bit more? (optional)