Skip to main content

Web Application Development MCQs with Answers

Practice important Web Application Development MCQs with answers and explanations.

Chapter: 2
Q21:
What data type is represented by $x = 10.365; in PHP?
A. Integer
B. Float
C. String
D. Boolean
Correct Answer: B
Chapter: 2
Q22:
Fill in the blank: A PHP float number can be specified in _______ form.
A. decimal, hexadecimal, octal
B. only decimal
C. only hexadecimal
D. only octal
Correct Answer: A
Chapter: 2
Q23:
Which statement about PHP objects is true?
A. An object must be explicitly declared
B. Objects are not used in PHP
C. Objects are declared using var
D. PHP objects are not allowed
Correct Answer: A
Chapter: 2
Q24:
What will be the output of <?php $COLOR = "blue"; echo $color; ?>?
A. blue
B. Blue
C. Nothing
D. Error
Correct Answer: A
Chapter: 2
Q25:
Fill in the blank: PHP supports data types such as string, integer, float, boolean, _______.
A. array
B. object
C. NULL
D. all of the above
Correct Answer: D
Chapter: 2
Q26:
What is the purpose of the var_dump() function in PHP?
A. To output variables with their type information
B. To print strings
C. To define variables
D. To create objects
Correct Answer: A
Chapter: 2
Q27:
What is the correct way to declare a PHP class?
A. class ClassName {}
B. declare class ClassName {}
C. class ClassName()
D. new ClassName {}
Correct Answer: A
Chapter: 3
Q28:
What is the main feature of PHP as a loosely typed language?
A. It requires explicit type declaration
B. It automatically converts variable data types
C. It uses static typing
D. It requires manual type conversion
Correct Answer: B
Chapter: 3
Q29:
Which keyword is used to access global variables within a function in PHP?
A. local
B. static
C. global
D. var
Correct Answer: C
Chapter: 3
Q30:
What will be the output of <?php $x = "Pakistan"; echo $x; ?>?
A. Pakistan
B. Error
C. 5
D. Nothing
Correct Answer: A
Chapter: 3
Q31:
Fill in the blank: A variable declared inside a function has _______ scope.
A. global
B. static
C. local
D. global
Correct Answer: C
Chapter: 3
Q32:
Which function returns the length of a string in PHP?
A. str_word_count
B. strlen
C. strrev
D. strpos
Correct Answer: B
Chapter: 3
Q33:
What will be the output of <?php echo strrev("Hello world!"); ?>?
A. Hello world!
B. !dlrow olleH
C. Error
D. Nothing
Correct Answer: B
Chapter: 3
Q34:
Fill in the blank: To replace text within a string, which PHP function is used?
A. str_word_count
B. str_replace
C. strrev
D. strlen
Correct Answer: B
Chapter: 3
Q35:
What is the purpose of the strpos() function in PHP?
A. To replace text within a string
B. To find the position of a substring in a string
C. To reverse a string
D. To count words in a string
Correct Answer: B
Chapter: 3
Q36:
Which of the following is true about PHP's local variables?
A. They can be accessed from any part of the script
B. They are deleted when the function completes
C. They can be accessed globally
D. They are not used in PHP
Correct Answer: B
Chapter: 3
Q37:
Fill in the blank: The define() function is used to create a _______ in PHP.
A. variable
B. constant
C. function
D. class
Correct Answer: B
Chapter: 3
Q38:
What will the output be if <?php $x = 5; function myTest() { global $x; $x = 10; } myTest(); echo $x; ?> is executed?
A. 5
B. 10
C. Error
D. Nothing
Correct Answer: B
Chapter: 3
Q39:
Which function counts the number of words in a string in PHP?
A. str_word_count
B. strlen
C. strrev
D. strpos
Correct Answer: A
Chapter: 3
Q40:
Fill in the blank: To declare a PHP constant that is case-insensitive, use the define() function with the _______ parameter set to true.
A. name
B. case-insensitive
C. value
D. global
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Web Application Development

🚀 Start Quiz Now