

MCQOPTIONS
Saved Bookmarks
This section includes 34 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.
1. |
What will be the output of the following php code? array( "population" => "11,35,000", "captial" => "Bangalore"),"Tamil Nadu" => array( "population" => "17,90,000","captial" => "Chennai") );echo $states["karnataka"]["population"];?> |
A. | arnataka 11,35,000 |
B. | 1,35,000 |
C. | opulation 11,35,000 |
D. | arnataka population |
Answer» C. opulation 11,35,000 | |
2. |
Which of the following are correct ways of creating an array?1. state[0] = “karnataka”;2. $state[] = array(“karnataka”);3. $state[0] = “karnataka”;4. $state = array(“karnataka”); |
A. | and 4 |
B. | and 3 |
C. | nly 1 |
D. | , 3 and 4 |
Answer» B. and 3 | |
3. |
What array will you get if you convert an object to an array? |
A. | n array with properties of that object as the array's elements |
B. | n array with properties of that array as the object's elements |
C. | n array with properties of that object as the Key elements |
D. | n array with keys of that object as the array's elements |
Answer» B. n array with properties of that array as the object's elements | |
4. |
What functions count elements in an array?1. count2. Sizeof3. Array_Count4. Count_array |
A. | ption 2 and 4 |
B. | ption 1 and 2 |
C. | ption 3 and 4 |
D. | ption 1 and 4 |
Answer» C. ption 3 and 4 | |
5. |
What function computes the difference of arrays? |
A. | rray_diff |
B. | iff_array |
C. | rrays_diff |
D. | iff_arrays |
Answer» B. iff_array | |
6. |
What will be the output of the following PHP code? |
A. | rangebanana |
B. | ppleorange |
C. | rangeorange |
D. | ppleapple |
Answer» B. ppleorange | |
7. |
What will be the output of the following PHP code? |
A. | rray ( [a] => blue [b] => yellow [c] => red [d] => green ) |
B. | rray ( [0] => blue [1] => yellow [2] => red [3] => green ) |
C. | rray ( [0] => red [1] => green [2] => blue [3] => yellow ) |
D. | rray ( [a] => red [b] => green [c] => blue [d] => yellow ) |
Answer» E. | |
8. |
What will be the output of the following PHP code? "red", "b" => "green", "c" => "blue", "d" => "yellow");$a2 = array("e" => "red", "f" => "green", "g" => "blue", "h" => "orange");$a3 = array("i" => "orange");$a4 = array_combine($a2, $a3);$result = array_diff($a4, $a2);print_r($result);?> |
A. | rray ( [d] => yellow ) |
B. | rray ( [i] => orange ) |
C. | rray ( [h] => orange ) |
D. | rray ( [d] => yellow [h] => orange ) |
Answer» B. rray ( [i] => orange ) | |
9. |
What will be the output of the following PHP code? |
A. | rray ( [A] => 5 [Cat] => 2 [Dog] => 2 [Tiger] => 1 ) |
B. | rray ( [A] => 2 [Cat] => 2 [Dog] => 1 [Tiger] => 1 ) |
C. | rray ( [A] => 6 [Cat] => 1 [Dog] => 2 [Tiger] => 1 ) |
D. | rray ( [A] => 2 [Cat] => 1 [Dog] => 4 [Tiger] => 1 ) |
Answer» B. rray ( [A] => 2 [Cat] => 2 [Dog] => 1 [Tiger] => 1 ) | |
10. |
What will be the output of the following PHP code ? |
A. | ucy |
B. | eter |
C. | usan |
D. | dmund |
Answer» C. usan | |
11. |
What will be the output of the following PHP code ? |
A. | rray ( [1] => Mumbai [0] => Beijing ) |
B. | rray ( [0] => NYC [1] => London ) |
C. | rray ( [1] => NYC [0] => London ) |
D. | rray ( [0] => Mumbai [1] => Beijing ) |
Answer» E. | |
12. |
What will be the output of the following PHP code ? "red", "b" => "green", "c" => "blue", "d" => "yellow");$result = array_flip($a1);print_r($result);?> |
A. | rray ( [red] => red [green] => green [blue] => blue [yellow] => yellow ) |
B. | rray ( [a] => a [b] => b [c] => c [d] => d ) |
C. | rray ( [red] => a [green] => b [blue] => c [yellow] => d ) |
D. | rray ( [a] => red [b] => green [c] => blue [d] => yellow ) |
Answer» D. rray ( [a] => red [b] => green [c] => blue [d] => yellow ) | |
13. |
What will be the output of the following PHP code ? "21", "Ron" => "23","Malfoy" => "21");array_change_key_case($age, CASE_UPPER);array_pop($age);print_r($age);?> |
A. | rray ( [Harry] => 21 [Ron] => 23 [Malfoy] => 21 ) |
B. | rray ( [HARRY] => 21 [RON] => 23 [MALFOY] => 21 ) |
C. | rray ( [HARRY] => 21 [RON] => 23 ) |
D. | rray ( [Harry] => 21 [Ron] => 23 ) |
Answer» D. rray ( [Harry] => 21 [Ron] => 23 ) | |
14. |
What will be the output of the following PHP code? |
A. | rray ( [0] => LA [1] => Paris [2] => Paris ) |
B. | rray ( [0] => NYC [1] => LA [2] => Paris) |
C. | rray ( [0] => NYC [1] => LA [2] => Paris [3] => Paris ) |
D. | one of the mentioned |
Answer» B. rray ( [0] => NYC [1] => LA [2] => Paris) | |
15. |
What will be the output of the following PHP code? |
A. | am is the brother of Bob and Bob) $brother |
B. | am is the brother of Bob and Bob) |
C. | brother |
D. | rror |
Answer» E. | |
16. |
What will be the output of the following PHP code? |
A. | rray ( Peter Ben Joe ) |
B. | rray ( [Peter] => 35 [Ben] => 37 [Joe] => 43 ) |
C. | rray ( 35 37 43 ) |
D. | rray ( “[Peter] => 35” “[Ben] => 37” “[Joe] => 43” ) |
Answer» C. rray ( 35 37 43 ) | |
17. |
What will be the output of the following PHP code? |
A. | rray ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) ) |
B. | rray ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) ) |
C. | rray ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) ) |
D. | rray ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) ) |
Answer» E. | |
18. |
What will be the output of the following PHP code?"35", "Ben"=>"37", "Joe"=>"43");print_r(array_change_key_case($age, CASE_UPPER));?> |
A. | rray ( [Peter] => 35 [Ben] => 37 [Joe] => 43 ) |
B. | rray ( [peter] => 35 [ben] => 37 [joe] => 43 ) |
C. | rray ( [PETER] => 35 [BEN] => 37 [JOE] => 43 ) |
D. | rray ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 ) |
Answer» D. rray ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 ) | |
19. |
What will be the output of the following PHP code? |
A. | rray ( [0] => red [1] => green ) |
B. | rray ( [0] => green [1] => blue ) |
C. | rray ( [0] => red [1] => blue ) |
D. | rray ( [0] => blue [1] => blue ) |
Answer» B. rray ( [0] => green [1] => blue ) | |
20. |
What will be the output of the following PHP code?"red", "b"=>"green", "c"=>"blue");echo array_shift($a);print_r ($a);?> |
A. | reen |
B. | ed |
C. | lue |
D. | one of the mentioned |
Answer» C. lue | |
21. |
What will be the output of the following PHP code? |
A. | rray ( [0] => red [1] => green) |
B. | rray ( [0] => blue [1] => yellow [2] => red [3] => green ) |
C. | rray ( [0] => red [1] => green [2] => blue [3] => yellow ) |
D. | rray ( [0] => blue [1] => yellow ) |
Answer» D. rray ( [0] => blue [1] => yellow ) | |
22. |
What will be the output of the following PHP code? |
A. | rray ( [0] => peach ) |
B. | rray ( [0] => apple [1] => mango [2] => peach ) |
C. | rray ( [0] => apple [1] => mango ) |
D. | rray ( [0] => peach [1] => pear [2] => orange ) |
Answer» E. | |
23. |
What will be the output of the following PHP code? |
A. | rray ( [0] => A [1] => J [2] => Q [3] => K [4] => 2 [5] => 3 [6] => 4 [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 ) |
B. | rray ( [0] => A [1] => 2 [2] => J [3] => 3 [4] => Q [5] => 4 [6] => K [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 ) |
C. | rror |
D. | rray ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 10 [9] => A [10] => J [11] => Q [12] => K ) |
Answer» B. rray ( [0] => A [1] => 2 [2] => J [3] => 3 [4] => Q [5] => 4 [6] => K [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 ) | |
24. |
What will be the output of the following PHP code? |
A. | rray ( [0] => picture1.JPG [1] => Picture10.jpg [2] => picture2.jpg [3] => picture20.jpg ) |
B. | rray ( [0] => picture1.JPG [1] => picture2.jpg [2] => Picture10.jpg [3] => picture20.jpg ) |
C. | rray ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture2.jpg [3] => picture20.jpg ) |
D. | rray ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg ) |
Answer» D. rray ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg ) | |
25. |
What will the following script output? |
A. | 8 |
B. | 9 |
C. | ULL |
Answer» B. 9 | |
26. |
ARRAY_(_[A]_=>_2_[CAT]_=>_1_[DOG]_=>_2_)?$ |
A. | Array ( [A] => 2 [Cat] => 2 [Dog] => 1 ) |
B. | Array ( [A] => 1 [Cat] => 1 [Dog] => 2 ) |
C. | Array ( [A] => 2 [Cat] => 1 [Dog] => 1) |
Answer» B. Array ( [A] => 1 [Cat] => 1 [Dog] => 2 ) | |
27. |
ORANGEBANANA?$ |
A. | appleorange |
B. | orangeorange |
C. | appleapple |
Answer» D. | |
28. |
Array ( Peter Ben Joe ) |
A. | Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 ) |
B. | Array ( 35 37 43 ) |
C. | Array ( “[Peter] => 35” “[Ben] => 37” “[Joe] => 43” ) |
Answer» D. | |
29. |
Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) ) |
A. | Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) ) |
B. | Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) ) |
C. | Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) ) |
Answer» B. Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) ) | |
30. |
Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 ) |
A. | Array ( [peter] => 35 [ben] => 37 [joe] => 43 ) |
B. | Array ( [PETER] => 35 [BEN] => 37 [JOE] => 43 ) |
C. | Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 ) |
Answer» C. Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 ) | |
31. |
karnataka 11,35,000 |
A. | 11,35,000 |
B. | population 11,35,000 |
C. | karnataka population |
Answer» C. karnataka population | |
32. |
I like Volvo BMW and Toyota) |
A. | I like Volvo, BMW and Toyota) |
B. | I like Volvo, BMW and Toyota |
C. | I like. Volvo.,. BMW. and) Toyota) |
Answer» D. | |
33. |
Which of the following are correct ways of creating an array? |
A. | state[0] = “karnataka”; |
B. | $state[] = array(“karnataka”); |
C. | $state[0] = “karnataka”; |
D. | $state = array(“karnataka”); |
Answer» B. $state[] = array(‚Äö√Ñ√∂‚àö√ë‚àö‚à´karnataka‚Äö√Ñ√∂‚àö√ë‚àöœÄ); | |
34. |
PHP’s numerically indexed array begin with position ___________ |
A. | 1 |
B. | 2 |
C. | 0 |
D. | -1 |
Answer» D. -1 | |