Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Chapter: 35
Q701:
PHP scripts are executed on which side?
A. Client-side
B. Browser-side
C. Server-side
D. User-side
Correct Answer:
C
Chapter: 35
Q702:
Which of the following is NOT a data type in PHP?
A. Boolean
B. Array
C. Resource
D. Enumeration
Correct Answer:
D
Chapter: 35
Q703:
What file extensions are commonly used for PHP files?
A. .php, .php3, .phtml
B. .html, .htm, .css
C. .js, .java, .php
D. .exe, .dll, .bat
Correct Answer:
A
Chapter: 35
Q704:
Which of the following data types does PHP support?
A. Boolean, integer, float, string, object
B. Integer, object, char, void
C. Float, boolean, struct, int
D. Double, list, hash, long
Correct Answer:
A
Chapter: 35
Q705:
PHP scripts can be embedded into which of the following?
A. HTML documents
B. Java programs
C. C++ files
D. Python scripts
Correct Answer:
A
Chapter: 35
Q706:
PHP variables start with which symbol?
A. #
B. &
C. $
D. *
Correct Answer:
C
Chapter: 35
Q707:
What is the output of the following code? <p>Hello World</p>
A. PHP script parsed
B. HTML document
C. CSS document
D. JavaScript document
Correct Answer:
B
Chapter: 35
Q708:
Which PHP tag style is not supported in some browsers?
A. Short tags
B. ASP-style tags
C. Heredoc
D. Full PHP tags
Correct Answer:
B
Chapter: 35
Q709:
How are strings created in PHP?
A. Single quote, double quote, heredoc
B. Backtick, angle bracket
C. Parentheses, curly braces
D. None of these
Correct Answer:
A
Chapter: 35
Q710:
Which operation will convert a string to a float in PHP?
A. Adding the string to a number
B. Subtracting from a string
C. Comparing to a float
D. Multiplying by a float
Correct Answer:
A
Chapter: 35
Q711:
What does unset($arr) do in PHP?
A. Deletes the last element of the array
B. Deletes a specific key
C. Deletes the entire array
D. Deletes the array structure only
Correct Answer:
C
Chapter: 35
Q712:
In the array $arr = array("foo" => "bar", 12 => true);, what is the value of $arr["foo"]?
A. 1
B. bar
C. foo
D. 1
Correct Answer:
B
Chapter: 35
Q713:
PHP is especially suited for which of the following?
A. Mobile app development
B. Web development
C. Desktop software development
D. Game development
Correct Answer:
B
Chapter: 35
Q714:
PHP supports which type of comments?
A. C-style only
B. HTML-style only
C. C++-style and single-line comments
D. Python-style comments
Correct Answer:
C
Chapter: 35
Q715:
Which of the following is the correct output for $foo = 2 + "10.5"; in PHP?
A. 12
B. 12.5
C. 105
D. Error
Correct Answer:
B
Chapter: 35
Q716:
What will be the type of $foo = 1 + "10 Small Cats";
A. Integer
B. String
C. Float
D. Boolean
Correct Answer:
A
Chapter: 35
Q717:
Which syntax is correct for defining an array in PHP?
A. array()
B. ArrayList()
C. list()
D. hash()
Correct Answer:
A
Chapter: 35
Q718:
The echo statement in PHP is used for:
A. Declaring variables
B. Outputting text
C. Running server scripts
D. Calling functions
Correct Answer:
B
Chapter: 36
Q719:
What does the add_item method in the Cart class do?
A. Removes items from the cart
B. Adds items to the cart
C. Updates the item quantity
D. Clears the cart
Correct Answer:
B
Chapter: 36
Q720:
In PHP, what symbol is used to assign by reference?
A. @
B. &
C. #
D. %
Correct Answer:
B