Tuesday, August 6, 2013

PHP MCQ Test – 3


Que.1. Which of following are compound data type?

A:        Array
B:        Objects
C:        Both
D:        None

Right Answer: C

Que.2. <?php
$x=array(2=>"apple",7=>"orange");
$y=array_keys($x);
echo $y[1];
?>

A:        apple
B:        orange
C:        7
D:        2


Right Answer: C

Que.3. How would you add 1 to the variable $count in PHP?

A:        incr count;
B:        $count++;
C:        $count =+1
D:        incr $count;

Right Answer: B

Que.4. Which of the following delimiting method is known as string Interpolation in PHP.

A:        delimited by single quote
B:        delimited by double quote
C:        delimited by <<< identifier
D:        All of above

Right Answer: C

Que.5. Trace the odd data type

A:        floats
B:        integer
C:        doubles
D:        Real number

Right Answer: B

Que.6. PHP variables are ___________.

A:        Multitype variables
B:        Double type variables
C:        Single type variable
D:        Trible type variables

Right Answer: A

Que.7. <?php
$qpt = 'Eat to live, but not live to eat';
echo preg_match("/^to/", $qpt);
?>
What is the output of following script?

A:        0
B:        1
C:        Null

Right Answer: A

Que.8. In PHP the error control operator is _______.

A:        #
B:        .
C:        @
D:        &

Right Answer: C

Que.9. <?php
$str="101.5degrees";
(double)$str;
(int)$str;
echo (string)$str;
?>

A:        101.5
B:        degrees
C:        101
D:        101.5degrees

Right Answer: D

Que.10. Which of the following is used to check if a function has already been defined?

A:        bool function_exists(functionname)
B:        bool f_exists(functionname)
C:        bool func_exist(functioname)

Right Answer: A

Que.11. In PHP, during error handling include() generates _______________.

A:        a fatal error, and the script will stop
B:        a warning, but the script will continue execution
C:        None of the above

Right Answer: B

Que.12. Which of the following function is used for terminate the script execution in PHP?

A:        break()
B:        quit()
C:        die()

Right Answer: C

Que.13. Which datatypes are treated as arrays?

A:        Integer
B:        Float
C:        String
D:        Booleans

Right Answer: C

Que.14. What happens if you add a string to an integer using the + operator?

A:        The interpreter outputs a type mismatch error
B:        The string is converted to a number and added to the integer
C:        The string is discarded and the integer is preserved
D:        The integer and string are concatenated together in a new string
E:         The integer is discarded and the string is preserved

Right Answer: B

Que.15. What function used to print statement in PHP?

A:        echo();
B:        printf
C:        ""

Right Answer: A

Que.16. What will the following script output?
<?php
$array = array (1, 2, 3, 5, 8, 13, 21, 34, 55);
$result = 0;
for ($i = 0; $i < 5; $i++) {
$result += $array[$array[$i]];
}
echo $result;
?>

A:        78
B:        19
C:        NULL
D:        5

Right Answer: A

Que.17. Is it possible to submit a form with out a submit button ?

A:        Yes
B:        No

Right Answer: A

Que.18. Which of the following function is used to pick one or more random values from PHP Array?

A:        array_rand()
B:        array_random()
C:        Random_array()
D:        Rand_array()

Right Answer: A

Que.19. What's the best way to copy a file from within a piece of PHP?

A:        Print out a message asking your user to "telnet" in to the server and copy the file for you
B:        Open the input and output files, and use read() and write() to copy the data block by block until read() returns a zero
C:        Use the built in copy() function
D:        Use "exec" to run an operating system command such as cp (Unix, Linux) or copy (Windows)

Right Answer: C

Que.20. For integer data type PHP 6 introduced

A:        8 bit integer value
B:        16 bit integer value
C:        32 bit integer value
D:        64 bit integer value

Right Answer: D

No comments:

Post a Comment