MCQOPTIONS
Saved Bookmarks
This section includes 40 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
PHP files have a default file extension of.. |
| A. | .html |
| B. | .xml |
| C. | .php |
| D. | .ph |
| Answer» D. .ph | |
| 2. |
What will be the output of the following PHP code ? $a = ""; if ($a) print "all"; if else print "some"; |
| A. | all |
| B. | some |
| C. | error |
| D. | no output |
| Answer» C. error | |
| 3. |
What will be the output of the following PHP code ? $a = 10; if (0) print "all"; if else print "some" |
| A. | all |
| B. | some |
| C. | error |
| D. | no output |
| Answer» D. no output | |
| 4. |
What will be the output of the following PHP code ? $a = 10; if (1) print "all"; else print "some" else print "none"; |
| A. | all |
| B. | some |
| C. | error |
| D. | none |
| Answer» D. none | |
| 5. |
What will be the output of the following PHP code ? $a = 1; if (print $a) print "True"; else print "False"; |
| A. | true |
| B. | false |
| C. | error |
| D. | no output |
| Answer» B. false | |
| 6. |
What will be the output of the following PHP code ? $a = 1; if (echo $a) print "True"; else print "False"; |
| A. | true |
| B. | false |
| C. | error |
| D. | no output |
| Answer» D. no output | |
| 7. |
What will be the output of the following PHP code ? $a = 1; if ($a--) print "True"; if ($a++) print "False"; |
| A. | true |
| B. | false |
| C. | error |
| D. | no output |
| Answer» B. false | |
| 8. |
What will be the output of the following PHP code ? $x = 0; if ($x == 1) if ($x >= 0) print "true"; else print "false"; |
| A. | true |
| B. | false |
| C. | error |
| D. | no output |
| Answer» E. | |
| 9. |
What will be the output of the following PHP code ? $x; if ($x == 0) print "hi" ; else print "how are u"; print "hello"; |
| A. | how are uhello |
| B. | hihello |
| C. | hi |
| D. | no output |
| Answer» C. hi | |
| 10. |
What will be the output of the following PHP code?$team = "arsenal"; switch ($team) { case "manu": echo "I love man u"; case "arsenal": echo "I love arsenal"; case "manc": echo "I love manc"; } |
| A. | I love arsenal |
| B. | Error |
| C. | I love arsenalI love manc |
| D. | I love arsenalI love mancI love manu |
| Answer» D. I love arsenalI love mancI love manu | |
| 11. |
What will be the output of the following PHP code ?$x = 0; if ($x++) print "hi"; else print "how are u"; |
| A. | hi |
| B. | no output |
| C. | error |
| D. | how are u |
| Answer» E. | |
| 12. |
What will be the output of the following PHP code?$x; if ($x) print "hi" ; else print "how are u"; |
| A. | how are u |
| B. | hi |
| C. | error |
| D. | no output |
| Answer» B. hi | |
| 13. |
Which of the conditional statements is/are supported by PHP?if statementsif-else statements if-elseif statementsswitch statements |
| A. | Only 1 |
| B. | 1, 2 and 4 |
| C. | 2, 3 and 4 |
| D. | All of the mentioned. |
| Answer» E. | |
| 14. |
What will be the output of the following PHP code?$num = 10; echo 'What is her age? n She is $num years old'; |
| A. | What is her age? n She is $num years old |
| B. | What is her age? She is $num years old |
| C. | What is her age? She is 10 years old |
| D. | What is her age?n She is 10 years old |
| Answer» B. What is her age? She is $num years old | |
| 15. |
What will be the output of the following PHP code?$a = "clue"; $a .= "get"; echo "$a"; |
| A. | get |
| B. | true |
| C. | false |
| D. | clueget |
| Answer» E. | |
| 16. |
What will be the output of the following code?function track() { static $count = 0; $count++; echo $count; } track(); track(); track(); |
| A. | 123 |
| B. | 111 |
| C. | 000 |
| D. | 011 |
| Answer» B. 111 | |
| 17. |
What will be the output of the following PHP code?$total = "25 students"; $more = 10; $total = $total + $more; echo "$total"; |
| A. | Error |
| B. | 35 students |
| C. | 35 |
| D. | 25 students |
| Answer» D. 25 students | |
| 18. |
What will be the output of the following PHP code?$score = 1234; $scoreboard = (array) $score; echo $scoreboard[0]; |
| A. | 1 |
| B. | Error |
| C. | 1234 |
| D. | 2 |
| Answer» D. 2 | |
| 19. |
What will be the output of the following PHP code?$color = "maroon"; $var = $color[2]; echo "$var"; |
| A. | a |
| B. | Error |
| C. | $var |
| D. | r |
| Answer» E. | |
| 20. |
Which of the following PHP statements will output Hello World on the screen?echo (“Hello World”);print (“Hello World”);printf (“Hello World”);sprintf (“Hello World”); |
| A. | 1 and 2 |
| B. | 1, 2 and 3 |
| C. | All of the mentioned |
| D. | 1, 2 and 4 |
| Answer» C. All of the mentioned | |
| 21. |
What will be the output of the following code? $foo = 'Bob'; $bar = &$foo; $bar = "My name is $bar"; echo $bar; echo $foo; ?> |
| A. | Error |
| B. | My name is BobBob |
| C. | My name is BobMy name is Bob |
| D. | My name is Bob Bob |
| Answer» D. My name is Bob Bob | |
| 22. |
Which of following variables can be assigned a value to it?$3hello$_hello$this$This |
| A. | All of the mentioned |
| B. | Only 2 |
| C. | 2, 3 and 4 |
| D. | 2 and 4 |
| Answer» E. | |
| 23. |
What will be the output of the following php code? $num = "1"; $num1 = "2"; print $num+$num1; ?> |
| A. | 3 |
| B. | 1+2 |
| C. | Error |
| D. | 12 |
| Answer» B. 1+2 | |
| 24. |
What will be the output of the following php code? $num = 1; $num1 = 2; print $num . "+". $num1; ?> |
| A. | 3 |
| B. | 1+2 |
| C. | 1.+.2 |
| D. | Error |
| Answer» C. 1.+.2 | |
| 25. |
Which of the following php statement/statements will store 111 in variable num?int $num = 111;int mum = 111;$num = 111;111 = $num; |
| A. | Both 1 and 2 |
| B. | All of the mentioned |
| C. | Only 3 |
| D. | Only 1 |
| Answer» D. Only 1 | |
| 26. |
We can use _________ to comment a single line? /?//#/* */ |
| A. | Only 2 |
| B. | 1, 3 and 4 |
| C. | 2, 3 and 4 |
| D. | Both 2 and 4 |
| Answer» D. Both 2 and 4 | |
| 27. |
What is the output of the following statements? int b=15, c=5, d=8, e=8, a; a = b>c ? c>d ? 12 : d>e ? 13 : 14 : 15; printf("%d", a); |
| A. | 13 |
| B. | 14 |
| C. | 15 |
| D. | 16 |
| Answer» C. 15 | |
| 28. |
What is the output of the following statements? int i = 0; printf("%d %d", i, i++); |
| A. | 0 1 |
| B. | 1 0 |
| C. | 0 0 |
| D. | 1 1 |
| Answer» C. 0 0 | |
| 29. |
What number will z in the sample code given below? int z, x=5, y= -10, a=4, b=2; z = x++ - --y*b/a; |
| A. | 5 |
| B. | 6 |
| C. | 9 |
| D. | 10 |
| Answer» E. | |
| 30. |
What will be the output? void main(){ int a=10, b=20; char x=1, y=0; if(a,b,x,y){ printf("EXAM"); } } |
| A. | XAM is printed |
| B. | exam is printed |
| C. | Compiler Error |
| D. | Nothing is printed |
| Answer» E. | |
| 31. |
What will be the output of this program on an implementation where int occupies 2 bytes? #include void main() { int i = 3; int j; j = sizeof(++i + ++i); printf("i=%d j=%d", i, j); } |
| A. | i=4 j=2 |
| B. | i=3 j=2 |
| C. | i=5 j=2 |
| D. | the behavior is undefined |
| Answer» C. i=5 j=2 | |
| 32. |
What will be the output of the following program? void main() { int a, b, c, d; a = 3; b = 5; c = a, b; d = (a, b); printf("c=%d d=%d", c, d); } |
| A. | c=3 d=3 |
| B. | c=3 d=5 |
| C. | c=5 d=3 |
| D. | c=5 d=5 |
| Answer» C. c=5 d=3 | |
| 33. |
Determine output: void main() { int i=10; i = !i>14; printf("i=%d", i); } |
| A. | 10 |
| B. | 14 |
| C. | 0 |
| D. | 1 |
| Answer» D. 1 | |
| 34. |
Determine output: void main() { int c = - -2; printf("c=%d", c); } |
| A. | 1 |
| B. | -2 |
| C. | 2 |
| D. | Error |
| Answer» D. Error | |
| 35. |
Determine output: void main() { int i=0, j=1, k=2, m; m = i++ || j++ || k++; printf("%d %d %d %d", m, i, j, k); } |
| A. | 1 1 2 3 |
| B. | 1 1 2 2 |
| C. | 0 1 2 2 |
| D. | 0 1 2 3 |
| Answer» C. 0 1 2 2 | |
| 36. |
Which of the following php statement/statements will store 111 in variable num? |
| A. | int $num = 111; |
| B. | int mum = 111; |
| C. | $num = 111; |
| D. | 111 = $num; |
| Answer» D. 111 = $num; | |
| 37. |
We can use ___ to comment a single line? |
| A. | /? |
| B. | // |
| C. | |
| Answer» D. | |
| 38. |
Which of the following must be installed on your computer so as to run PHP script? |
| A. | Adobe Dreamweaver |
| B. | PHP |
| C. | Apache |
| D. | IIS |
| Answer» E. | |
| 39. |
Which of the following is/are a PHP code editor? |
| A. | Notepad |
| B. | Notepad++ |
| C. | Adobe Dreamweaver |
| D. | PDT |
| Answer» C. Adobe Dreamweaver | |
| 40. |
What is the full form of PHP in Basics? |
| A. | Personal Home Page |
| B. | Hypertext Preprocessor |
| C. | Pretext Hypertext Processor |
| D. | Preprocessor Home Page |
| Answer» E. | |