Chapter: Introduction to Object Oriented Programming in PHP
1.
Which method scope prevents a method from being overridden by a subclass?
A.
Abstract
B.
Protected
C.
Final
D.
Static
Answer»
C. Final
2.
Which of the following statements are true 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.
A.
All of the mentioned
B.
None of the mentioned
C.
only i
D.
only ii
Answer»
A. All of the mentioned
3.
PHP recognize constructors by the name.
A.
class name()
B.
_construct()
C.
function _construct()
D.
function __construct()
Answer»
D. function __construct()
4.
Which version of PHP introduced the instance of keyword?
A.
PHP 4
B.
PHP 5
C.
PHP 5.3
D.
PHP 6
Answer»
B. PHP 5
5.
Which one of the following functions is used to determine whether a class exists?
A.
exist()
B.
exist_class()
C.
class_exist()
D.
exist()
Answer»
C. class_exist()
6.
Which one of the following functions is used to determine object type?
A.
obj_type()
B.
type()
C.
is_a()
D.
is_obj()
Answer»
C. is_a()
7.
Which one of the following keyword is used to inherit our subclass into a superclass?
A.
. extends
B.
. implements
C.
. inherit
D.
. include
Answer»
A. . extends
8.
Which keyword is used to refer to properties or methods within the class itself?
A.
. private
B.
public
C.
protected
D.
. $this
Answer»
D. . $this
9.
Which keyword allows class members (methods and properties) to be used without
needing to instantiate a new instance of the class?
A.
protected
B.
. final
C.
static
D.
private
Answer»
C. static
10.
_________ is a blue print of any object in OOP.
A.
class
B.
object
C.
Construct
D.
Serializing
Answer»
A. class
11.
An _____ is an instance or occurrence of our class.....
A.
class
B.
object
C.
Construct
D.
Serializing
Answer»
B. object
12.
The _____ method starts with two underscores (__).
A.
class
B.
object
C.
Construct
D.
Serializing
Answer»
C. Construct
13.
_______an object means converting it to a byte stream representation that can be
stored into file.
A.
class
B.
object
C.
Construct
D.
Serializing
Answer»
D. Serializing
14.
A class property used by another class is called ______.
A.
Abstract class
B.
Interface
C.
Encapsulation
D.
inheritance.
Answer»
D. inheritance.
15.
_________is used to support multiple inheritance
A.
Abstract class
B.
Interface
C.
Encapsulation
D.
inheritance.
Answer»
B. Interface
16.
The ability to hide the details of implementation is known as _____.
A.
Abstract class
B.
Interface
C.
Encapsulation
D.
inheritance.
Answer»
C. Encapsulation
17.
An _______ is one that cannot be instantiated, only inherited
A.
Abstract class
B.
Interface
C.
Encapsulation
D.
inheritance.
Answer»
A. Abstract class
18.
Constant name are proceeded by _____ like a normal variable declaration.
A.
Abstract class
B.
dollar sign($)
C.
Encapsulation
D.
inheritance.
Answer»
B. dollar sign($)
19.
_______ is available when a method is called from within an object context
A.
Abstract class
B.
dollar sign($)
C.
$this
D.
inheritance.
Answer»
C. $this
20.
in PHP, An _____is a special variable, which can hold more than one value at
a time.
A.
array
B.
structure
C.
csss
D.
none of these
Answer»
A. array
21.
In PHP, there are three types of arrays:
A.
Indexed arrays -
B.
Associative arrays -
C.
Multidimensional arrays -
D.
all of the above
Answer»
D. all of the above
22.
in PHP ,The____ function is used to return the length (the number of
elements) of an array:
A.
count
B.
min
C.
abs
D.
sqrt()
Answer»
A. count
23.
The index can be assigned automatically (index always starts at 0), like
this: $cars = array("Volvo", "BMW", "Toyota");
A.
true
B.
false
C.
both a and b
D.
none of these
Answer»
A. true
24.
The _____ functions can be used to find the lowest or highest value in a list of
arguments:
A.
count & num
B.
min & max
C.
abs & count
D.
sqrt() & round
Answer»
B. min & max
25.
The _____ function returns the absolute (positive) value of a number:
A.
count
B.
min
C.
abs
D.
sqrt()
Answer»
C. abs
26.
the _____function returns the square root of a number:
A.
count
B.
min
C.
abs
D.
sqrt()
Answer»
D. sqrt()
27.
The _____function rounds a floating-point number to its nearest integer:
A.
round
B.
min
C.
abs
D.
sqrt()
Answer»
A. round
28.
The _______ function generates a random number:
A.
rand
B.
min
C.
abs
D.
sqrt()
Answer»
A. rand
29.
To create a constant, use the _____ function.is used
A.
define()
B.
min()
C.
abs()
D.
sqrt()
Answer»
A. define()
30.
In PHP7, you can create an Array constant using the ____ function.
A.
define()
B.
min()
C.
abs()
D.
sqrt()
Answer»
A. define()
31.
The ____statement is used to perform different actions based on
different conditions.
A.
switch
B.
min
C.
abs
D.
sqrt()
Answer»
A. switch
32.
The PHP ____function formats a timestamp to a more readable date and time.
A.
date()
B.
min()
C.
abs()
D.
sqrt()
Answer»
A. date()
33.
A ______is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.
A.
cookie
B.
session
C.
abs
D.
sqrt
Answer»
A. cookie
34.
A ______ is a way to store information (in variables) to be used
across multiple pages.
A.
cookie
B.
session
C.
abs
D.
sqrt
Answer»
B. session
35.
_______are the two main aspects of object-oriented programming.
A.
classes and objects
B.
constructor and destructor
C.
object and array
D.
none of these
Answer»
A. classes and objects
36.
A ______allows you to initialize an object's properties upon creation of the
object.
A.
classes
B.
constructor
C.
object
D.
none of these
Answer»
B. constructor
37.
If you create a __construct() function, PHP will automatically call this
function when you create an object from a class.
A.
true
B.
false
C.
both a and b
D.
none of these
Answer»
A. true
38.
A ______is called when the object is destructed or the script is stopped or
exited.
A.
destructor
B.
constructor
C.
object
D.
none of these
Answer»
A. destructor
39.
If you create a __destruct() function, PHP will automatically call this
function at the end of the script.