PHP Language | 20 Minute‐Test 4


Instruction

  • Total number of questions : 20.
  • Time alloted : 20 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

What does PHP stand for?
i) Personal Home Page
ii) Hypertext Preprocessor
iii) Pretext Hypertext Processor
iv) Preprocessor Home Page

A.
Both i) and iii)
B.
Both ii) and iv)
C.
Only ii)
D.
Both i) and ii)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

PHP previously stood for Personal Home Page now stands for Hypertext Preprocessor.

2.

Which of following variables can be assigned a value to it?
i) $3hello
ii) $_hello
iii) $this
iv) $This

A.
All of the mentioned
B.
Only ii)
C.
ii), iii) and iv)
D.
ii) and iv)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

A variable can’t start with a number. Also $this is a special variable that can’t be assigned, but $This can be assigned.

3.

What will be the output of the following PHP code?

    <?php

    $a = 5;

    $b = 5;

    echo ($a === $b);

    ?>

A.
5 === 5
B.
Error
C.
1
D.
False

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

=== operator returns 1 if $a and $b are equivalent and $a and $b have the same type.

4.

Which one of the following is the right way of defining a function in PHP?

A.
function { function body }
B.
data type functionName(parameters) { function body }
C.
functionName(parameters) { function body }
D.
function fumctionName(parameters) { function body }

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

5.

Which one of the following PHP functions can be used to build a function that accepts any number of arguments?

A.
func_get_argv()
B.
func_get_args()
C.
get_argv()
D.
get_argc()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Here is an example-
function foo()
{
$args = func_get_args();
foreach ($args as $k => $v)
{
echo “arg”.($k+1).”: $v\n”;
}
}
foo();
/* will print nothing */
foo(“Hello”);
/* will print Hello */
foo(“Hello”,”World”,”Bye”);
/* will print Hello World Bye */

6.

PHP’s numerically indexed array begin with position __.

A.
1
B.
2
C.
0
D.
-1

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Like many programming languages, the first element of an array has an index value of 0.

7.

What will be the output of the following PHP code ?

<?php

$age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");

array_change_key_case($age, CASE_UPPER);

array_pop($age);

print_r($age);

?>

A.
Array ( [Harry] => 21 [Ron] => 23 [Malfoy] => 21 )
B.
Array ( [HARRY] => 21 [RON] => 23 [MALFOY] => 21 )
C.
Array ( [HARRY] => 21 [RON] => 23 )
D.
Array ( [Harry] => 21 [Ron] => 23 )

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The array_change_key_case() function changes all keys in an array to lowercase or uppercase and arry_pop() removes last element

8.

What will be the output of the following PHP code?

<?php

$cars = array("Volvo", "BMW", "Toyota");

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>

A.
I like Volvo BMW and Toyota.
B.
I like Volvo, BMW and Toyota.
C.
I like Volvo, BMW and Toyota
D.
I like. Volvo.,. BMW. and Toyota .

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The array() function is used to create an array.

9.

What will be the output of the following PHP code?

    <?php

    $fruits = array ("mango", "apple", "pear", "peach");

    $fruits = array_flip($fruits);

    echo ($fruits[0]);

    ?>

A.
mango
B.
Error
C.
peach
D.
0

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

As we are flipping the values, $fruits[“mango”] = 0, $fruits[“apple”] = 1 and so on.

10.

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

A.
Polymorphism
B.
Inheritance
C.
Encapsulation
D.
Abstraction

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

11.

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

A.
Abstract
B.
Protected
C.
Final
D.
Static

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

12.

Which of the following advanced OOP features is/are not supported by PHP?
i) Method overloading
ii) Multiple Inheritance
iii) Namespaces
iv) Object Cloning

A.
All of the mentioned
B.
None of the mentioned
C.
i) and ii)
D.
iii) and iv)

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The advanced OOP features are: Object cloning, Inheritance, Interfaces, Abstract classes, and Namespaces.

13.

How many error levels are available in PHP?

A.
14
B.
15
C.
16
D.
17

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

14.

Which version of PHP was added with Exception handling?

A.
PHP 4
B.
PHP 5
C.
PHP 5.3
D.
PHP 6

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Exception handling was added to PHP with the version 5 release, and further enhanced with version 5.3.

15.

Which of the following is/are an external data?
i) Cookies
ii) Input data from a form
iii) Server Variables
iv) Web services data

A.
Only ii)
B.
ii) and iii)
C.
None of the mentioned
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

16.

PHP has long supported two regular expression implementations known as ___ and ___.
i) Perl
ii) PEAR
iii) Pearl
iv) POSIX

A.
i) and ii)
B.
ii) and iv)
C.
i) and iv)
D.
ii) and iii)

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

none

17.

How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.

A.
7
B.
8
C.
9
D.
10

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The functions are preg_filter(), preg_grep(), preg_match(), preg_match_all(), preg_quote(), preg_replace(), preg_replace_callback(), and preg_split().

18.

The filesize() function returns the file size in ___.

A.
bits
B.
bytes
C.
kilobytes
D.
gigabytes

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

19.

What will be the output of the following PHP code?

    <?php

    echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');

    ?>

A.
TRUE
B.
FALSE
C.
Valid
D.
Invalid

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

April has 30 days and the above date is 31 therefore Invalid is returned.

20.

How many methods does the DateTime class have?

A.
8
B.
9
C.
10
D.
11

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The DateTime class has nine methods, all of which are public.

Submit your test now to view the Results and Statistics with answer explanation.