PHP Language | 10 Minute‐Test 11


Instruction

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

1.

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.

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

2.

Which version of PHP introduced the advanced concepts of OOP?

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

3.

What is the description of Error level E_ERROR?

A.
Fatal run-time error
B.
Near-fatal error
C.
Compile-time error
D.
Fatal Compile-time error

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

4.

How many methods are available for the exception class?

A.
5
B.
6
C.
7
D.
8

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The seven methods are: getCode(), getFile(), getLine(), getMessage(), getPrevious(), getTrace(), getTraceAsString()

5.

How many types of filtering are present in PHP?

A.
3
B.
2
C.
4
D.
None

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

There are two main types of filtering: validation and sanitization.

6.

Which one of the following regular expression matches any string containing zero or one p?

A.
p+
B.
p*
C.
P?
D.
p#

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None

7.

What will be the output of the following PHP code?

    <?php

    $foods = array("pasta", "steak", "fish", "potatoes");

    $food = preg_grep("/^s/", $foods);

    print_r($food);

    ?>

A.
Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes )
B.
Array ( [3] => potatoes )
C.
Array ( [1] => steak )
D.
Array ( [0] => potatoes )

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

This function is used to search an array for foods beginning with s.

8.

Which one of the following PHP function is used to determine a file’s last access time?

A.
fileltime()
B.
filectime()
C.
fileatime()
D.
filetime()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The fileatime() function returns a file’s last access time in Unix timestamp format or FALSE on error.

9.

The date() function returns ___ representation of the current date and/or time.

A.
Integer
B.
String
C.
Boolean
D.
Float

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The prototype of this function is: string date(string format [, int timestamp])

10.

How many constants does the DateTime class have?

A.
8
B.
9
C.
10
D.
11
Submit your test now to view the Results and Statistics with answer explanation.