Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Chapter: 36
Q721:
A variable that holds the address of another variable is called a ______.
A. pointer
B. variable variable
C. constant
D. alias
Correct Answer:
B
Chapter: 36
Q722:
Which operator in PHP is used for string concatenation?
A. .
B. +
C. &
D. =
Correct Answer:
A
Chapter: 36
Q723:
In PHP, which logical operator has the highest precedence?
A. and
B. or
C. xor
D. &&
Correct Answer:
D
Chapter: 36
Q724:
What does the foreach loop primarily work on?
A. Strings
B. Arrays
C. Constants
D. Variables
Correct Answer:
B
Chapter: 36
Q725:
What will the following code output? $a = "Hello"; $b = $a . " World!"; echo $b;
A. Hello
B. HelloWorld
C. Hello World!
D. Error
Correct Answer:
C
Chapter: 36
Q726:
What is the purpose of the switch statement in PHP?
A. Repeat a block of code
B. Branch based on multiple conditions
C. Declare variables
D. Define constants
Correct Answer:
B
Chapter: 36
Q727:
The === operator in PHP checks for ______.
A. Equality of values only
B. Equality of type only
C. Both value and type equality
D. None of the above
Correct Answer:
C
Chapter: 36
Q728:
Which array operator in PHP appends the second array to the first without overwriting duplicated keys?
A. +
B. ==
C. ===
D. !=
Correct Answer:
A
Chapter: 36
Q729:
In the Cart class, what happens when remove_item is called and the quantity becomes zero?
A. The item is retained
B. The item is removed from the cart
C. An error is returned
D. The cart is reset
Correct Answer:
B
Chapter: 36
Q730:
Which PHP control statement is used to iterate over arrays?
A. for
B. if
C. foreach
D. switch
Correct Answer:
C
Chapter: 36
Q731:
Which statement about PHP constants is TRUE?
A. Constants can change during execution
B. Constants are not case-sensitive
C. Constants follow variable naming rules
D. Constants must start with a number
Correct Answer:
C
Chapter: 36
Q732:
What will $foo contain after the following code? $foo = 'A'; $bar = &$foo; $bar = 'B';
A. A
B. B
C. Error
D. NULL
Correct Answer:
B
Chapter: 36
Q733:
In PHP, which function is used to retrieve the current key-value pair of an array?
A. key()
B. value()
C. each()
D. pointer()
Correct Answer:
C
Chapter: 36
Q734:
What does the & symbol before a variable in a foreach loop do?
A. Assigns by reference
B. Concatenates strings
C. Checks equality
D. Declares a constant
Correct Answer:
A
Chapter: 37
Q735:
What does the break statement do in PHP?
A. Exits a loop structure
B. Skips the current iteration
C. Restarts the loop
D. None of the above
Correct Answer:
A
Chapter: 37
Q736:
How many levels of nested structures can break exit in PHP?
A. Only one
B. Unlimited
C. A specified number using an argument
D. None of the above
Correct Answer:
C
Chapter: 37
Q737:
What will the PHP script output if the case 10 in the switch is reached?
A. "At 5"
B. "At 10; quitting"
C. "Case 10 executed"
D. None of the above
Correct Answer:
B
Chapter: 37
Q738:
The continue statement is used to:
A. Exit the loop
B. Skip the current iteration
C. Repeat the current iteration
D. None of the above
Correct Answer:
B
Chapter: 37
Q739:
In PHP, the switch statement is considered a looping structure for:
A. break
B. continue
C. Both break and continue
D. Neither
Correct Answer:
B
Chapter: 37
Q740:
What syntax is used for PHP's alternative control statements?
A. Curly braces
B. Colon : and end keywords
C. Parentheses
D. None of the above
Correct Answer:
B