"Welcome to our PHP 101 blog, where we demystify the world of web development. "

Monday, September 2, 2024

CLASS 3-Operators and Expressions in PHP(MCQ)

 MULTIPLE CHOICE QUSTION SET 3


Operators and Expressions in PHP

1. What will be the result of the following PHP expression?

$var = 10 + 5 * 2;

echo $var;

a) 20
b) 30
c) 15
d) 25

Answer: b) 20

2. Which operator is used for equality comparison in PHP?

a) =
b) ==
c) ===
d) !=

Answer: b) ==

3. What is the result of the following PHP code?

$x = 10;

$y = 5;

echo $x % $y;

a) 0
b) 5
c) 10
d) 2

Answer: a) 0

4. How do you concatenate two strings in PHP?

a) +
b) .
c) &
d) *

Answer: b) .

5. What will be the output of the following PHP code?

$var1 = true;

$var2 = false;

echo $var1 && $var2;

a) true
b) false
c) 1
d) 0

Answer: b) false

6. Which operator is used to check if two values are not identical in PHP?

a) !=
b) !==
c) ==
d) ===

Answer: b) !==

7. What will be the result of the following PHP code?

$val = 10;

$val += 5;

echo $val;

a) 5
b) 10
c) 15
d) 50

Answer: c) 15

8. What does the || operator do in PHP?

a) Logical AND
b) Logical OR
c) Bitwise AND
d) Bitwise OR

Answer: b) Logical OR

9. What will be the result of the following PHP code?

$a = 10;

$b = 5;

echo $a / $b;

a) 2
b) 5
c) 50
d) 10

Answer: a) 2

10. How do you increment a variable by 1 in PHP?

a) $var = $var + 1;
b) $var++;
c) $var += 1;
d) Both b) and c)

Answer: d) Both b) and c)

11. What is the result of the following PHP code?

$x = 5;

$y = "5";

echo $x === $y;

a) true
b) false
c) 1
d) 0

Answer: b) false

12. Which of the following operators is used to perform bitwise operations in PHP?

a) &&
b) ||
c) &
d) ^

Answer: c) &

13. What will be the output of the following PHP code?

$var = 10;

$var *= 2;

echo $var;

a) 20
b) 10
c) 100
d) 5

Answer: a) 20

14. What will be the result of the following PHP code?

$a = 4;

$b = 2;

echo $a ** $b;

a) 6
b) 8
c) 4
d) 2

Answer: b) 8

15. Which of the following statements is true about the & operator in PHP?

a) It is used for logical AND operations.
b) It is used for bitwise AND operations.
c) It is used for comparison.
d) It is used for concatenation.

Answer: b) It is used for bitwise AND operations.

16. What will be the result of the following PHP code?

$x = 10;

$y = 5;

echo $x > $y ? "Yes" : "No";

a) Yes
b) No
c) 10
d) 5

Answer: a) Yes

17. How do you perform a bitwise OR operation in PHP?

a) |
b) ||
c) &
d) ^

Answer: a) |

18. What is the result of the following PHP code?

$var = 20;

$var /= 4;

echo $var;

a) 5
b) 10
c) 20
d) 4

Answer: b) 5

19. What will be the output of the following PHP code?

$a = 5;

$b = 10;

echo $a <=> $b;

a) -1
b) 0
c) 1
d) Error

Answer: a) -1

20. What is the result of the following PHP code?

$x = 10;

$y = 20;

echo $x & $y;

a) 10
b) 20
c) 30
d) 0

Answer: a) 0

21. What will be the result of the following PHP code?

$a = 15;

$b = 4;

echo $a % $b;

a) 3
b) 4
c) 15
d) 7

Answer: a) 3

22. Which operator is used to perform exponentiation in PHP?

a) ^
b) **
c) *
d) **=

Answer: b) **

23. What is the result of the following PHP code?

$x = 7;

$y = 10;

echo $x < $y && $x != $y;

a) true
b) false
c) 1
d) 0

Answer: a) true

24. Which of the following PHP operators is used for string concatenation?

a) .
b) +
c) &
d) *

Answer: a) .

25. What will be the result of the following PHP code?

$x = 5;

$y = 3;

echo $x-- + ++$y;

a) 9
b) 8
c) 7
d) 10

Answer: a) 9

26. How do you perform a logical NOT operation in PHP?

a) !
b) &&
c) ||
d) ^

Answer: a) !

27. What will be the output of the following PHP code?

$var = 8;

$var += 3;

$var -= 5;

echo $var;

a) 6
b) 8
c) 9
d) 5

Answer: a) 6

28. What is the result of the following PHP code?

$a = 7;

$b = 3;

echo $a ** $b;

a) 21
b) 343
c) 10
d) 7

Answer: b) 343

29. Which operator is used to perform bitwise XOR in PHP?

a) &
b) |
c) ^
d) &&

Answer: c) ^

30. What will be the result of the following PHP code?

$x = 3;

$y = 2;

echo $x ** $y;

a) 5
b) 9
c) 6
d) 7

Answer: b) 9

31. Which of the following PHP operators is used to perform a logical AND operation?

a) &&
b) &
c) ||
d) ^

Answer: a) &&

32. What is the result of the following PHP code?

$var = 5;

$var -= 2;

$var *= 3;

echo $var;

a) 9
b) 15
c) 21
d) 11

Answer: c) 9

33. What will be the result of the following PHP code?

$x = 5;

$y = 10;

echo $x == $y ? "Equal" : "Not Equal";

a) Equal
b) Not Equal
c) true
d) false

Answer: b) Not Equal

34. How do you perform a bitwise left shift in PHP?

a) <<
b) >>
c) &
d) <<=

Answer: a) <<

35. What is the result of the following PHP code?

$x = 5;

$y = 5;

echo $x === $y;

a) true
b) false
c) 1
d) 0

Answer: a) true

36. Which of the following operators is used for assignment in PHP?

a) ==
b) =
c) ===
d) +=

Answer: b) =

37. What will be the result of the following PHP code?

$a = 6;

$b = 4;

echo $a & $b;

a) 6
b) 4
c) 2
d) 0

Answer: c) 4

38. What does the !== operator do in PHP?

a) Checks if two values are not equal.
b) Checks if two values are not identical.
c) Checks if two values are equal.
d) Checks if two values are identical.

Answer: b) Checks if two values are not identical.

39. How do you perform a bitwise OR operation in PHP?

a) |
b) ||
c) &
d) &&

Answer: a) |

40. What will be the result of the following PHP code?

$var = 12;

$var /= 4;

echo $var;

a) 3
b) 12
c) 4
d) 16

Answer: a) 3

41. What will be the result of the following PHP code?

$x = 15;

$y = 3;

echo $x / $y + $x % $y;

a) 7
b) 10
c) 8
d) 5

Answer: b) 10

42. Which operator is used to check if a variable is not empty in PHP?

a) !
b) !=
c) !==
d) empty()

Answer: d) empty()

43. What will be the result of the following PHP code?

$x = 8;

$y = 5;

echo $x + $y / 2;

a) 10
b) 13
c) 15
d) 9.5

Answer: d) 10

44. What is the result of the following PHP code?

$x = 7;

$y = 3;

$z = 5;

echo ($x + $y) * $z;

a) 50
b) 35
c) 60
d) 25

Answer: c) 50

45. How do you perform a bitwise right shift in PHP?

a) <<
b) >>
c) &
d) ^

Answer: b) >>

46. What will be the result of the following PHP code?

$x = 8;

$y = 4;

echo $x % $y + $y;

a) 4
b) 8
c) 12
d) 16

Answer: b) 8

47. What is the result of the following PHP code?

$x = 3;

$y = 2;

$z = 1;

echo $x + $y * $z;

a) 6
b) 5
c) 4
d) 7

Answer: b) 5

48. Which operator is used to perform a logical OR operation in PHP?

a) ||
b) &&
c) |
d) ^

Answer: a) ||

49. What will be the result of the following PHP code?

$x = 5;

$y = 10;

echo ($x < $y) ? "Yes" : "No";

a) Yes
b) No
c) 1
d) 0

Answer: a) Yes

50. What is the result of the following PHP code?

$a = 2;

$b = 3;

$c = 4;

echo $a * ($b + $c);

a) 14
b) 10
c) 20
d) 24

Answer: d) 20

51. Which operator in PHP is used to perform a modulus operation?

a) %
b) /
c) *
d) //

Answer: a) %

52. What will be the output of the following PHP code?

$x = 5;

$y = 2;

echo $x ** $y;

a) 10
b) 25
c) 7
d) 3

Answer: b) 25

53. What will be the result of the following PHP code?

php

Copy code

$a = 10;

$b = 4;

$c = 3;

echo ($a - $b) * $c;

a) 18
b) 30
c) 40
d) 28

Answer: a) 18

54. How do you perform an addition assignment in PHP?

a) $var += 5;
b) $var =+ 5;
c) $var + 5;
d) $var = $var + 5;

Answer: a) $var += 5;

55. What is the result of the following PHP code?

$x = 10;

$y = 5;

echo $x <=> $y;

a) -1
b) 0
c) 1
d) Error

Answer: c) 1

56. What will be the result of the following PHP code?

$val = 8;

$val -= 3;

$val /= 2;

echo $val;

a) 2
b) 3
c) 5
d) 4

Answer: d) 2.5

57. Which operator is used to perform bitwise AND in PHP?

a) |
b) &
c) ^
d) &&

Answer: b) &

58. What is the result of the following PHP code?

$x = 6;

$y = 3;

echo $x / $y * 2;

a) 4
b) 6
c) 2
d) 12

Answer: d) 4

59. What will be the result of the following PHP code?

$a = 5;

$b = 5;

echo $a == $b ? "Match" : "No Match";

a) Match
b) No Match
c) true
d) false

Answer: a) Match

60. What does the += operator do in PHP?

a) Assigns the value of the right operand to the left operand.
b) Adds the right operand to the left operand and assigns the result to the left operand.
c) Subtracts the right operand from the left operand and assigns the result to the left operand.
d) Multiplies the left operand by the right operand and assigns the result to the left operand.

Answer: b) Adds the right operand to the left operand and assigns the result to the left operand.

61. What will be the result of the following PHP code?

$x = 12;

$y = 5;

echo $x % $y + $x / $y;

a) 2.4
b) 4.4
c) 7.4
d) 8.4

Answer: c) 8.4

62. Which PHP operator is used to perform a bitwise NOT operation?

a) !
b) ~
c) ^
d) &

Answer: b) ~

63. What will be the result of the following PHP code?

$a = 5;

$b = 10;

$c = 2;

echo $a * $b / $c;

a) 10
b) 25
c) 20
d) 30

Answer: d) 25

64. Which operator is used to perform a bitwise left shift in PHP?

a) <<
b) >>
c) &
d) |

Answer: a) <<

65. What is the result of the following PHP code?

$x = 4;

$y = 3;

echo $x ** $y;

a) 27
b) 64
c) 12
d) 7

Answer: a) 64

66. How do you perform a bitwise right shift operation in PHP?

a) <<
b) >>
c) &
d) |

Answer: b) >>

67. What will be the result of the following PHP code?

$a = 10;

$b = 5;

$c = 2;

echo ($a + $b) % $c;

a) 1
b) 0
c) 2
d) 5

Answer: b) 0

68. Which PHP operator is used for concatenating strings?

a) +
b) .
c) &
d) ,

Answer: b) .

69. What will be the result of the following PHP code?

$x = 7;

$y = 3;

echo $x / $y + $x % $y;

a) 4
b) 3
c) 5
d) 7

Answer: a) 5

70. What is the result of the following PHP code?

$x = 8;

$y = 2;

$z = 3;

echo ($x - $y) * $z;

a) 6
b) 14
c) 24
d) 10

Answer: b) 18

71. What will be the result of the following PHP code?

$a = 15;

$b = 6;

$c = 2;

echo ($a - $b) / $c;

a) 4
b) 7
c) 8
d) 5

Answer: b) 4.5

72. Which operator is used to check if two values are identical in PHP?

a) !=
b) ==
c) ===
d) !==

Answer: c) ===

73. What will be the output of the following PHP code?

$x = 4;

$y = 2;

$z = 3;

echo $x ** $y + $z;

a) 19
b) 13
c) 8
d) 27

Answer: a) 19

74. What is the result of the following PHP code?

$x = 5;

$y = 7;

echo $x + $y * 2;

a) 12
b) 19
c) 17
d) 14

Answer: b) 19

75. What does the && operator do in PHP?

a) Performs a bitwise AND operation.
b) Performs a logical AND operation.
c) Performs a bitwise OR operation.
d) Performs a logical OR operation.

Answer: b) Performs a logical AND operation.

76. What will be the result of the following PHP code?

$x = 6;

$y = 2;

echo $x % $y * $y;

a) 4
b) 6
c) 12
d) 0

Answer: b) 0

77. What is the result of the following PHP code?

$a = 5;

$b = 2;

echo $a ** $b;

a) 7
b) 10
c) 25
d) 4

Answer: c) 25

78. How do you perform a modulus operation in PHP?

a) +
b) -
c) *
d) %

Answer: d) %

79. What will be the output of the following PHP code?

$x = 8;

$y = 3;

echo $x & $y;

a) 11
b) 10
c) 8
d) 0

Answer: c) 0

80. What is the result of the following PHP code?

$x = 10;

$y = 4;

$z = 2;

echo ($x + $y) / $z;

a) 7
b) 8
c) 5
d) 6

Answer: b) 7

 


********************************

 

 


No comments:

Post a Comment

Pages

SoraTemplates

Best Free and Premium Blogger Templates Provider.

Buy This Template