Skip to main content

Modern Programming Languages MCQs with Answers

Practice important Modern Programming Languages MCQs with answers and explanations.

Chapter: 37
Q741:
PHP allows functions to be defined:
A. Only inside classes
B. Inside other functions
C. At the global scope only
D. Inside arrays
Correct Answer: B
Chapter: 37
Q742:
Which of the following languages do not support defining functions inside functions?
A. PHP
B. JavaScript
C. C
D. C and descendants of Algol
Correct Answer: C
Chapter: 37
Q743:
What keyword is used for inheritance in PHP?
A. extend
B. extends
C. implements
D. None of the above
Correct Answer: B
Chapter: 37
Q744:
How can you pass a parameter by reference in PHP?
A. Using an asterisk (*)
B. Using a dollar sign ($)
C. Using an ampersand (&)
D. None of the above
Correct Answer: C
Chapter: 37
Q745:
PHP classes support:
A. Single inheritance only
B. Multiple inheritance
C. Both single and multiple inheritance
D. None of the above
Correct Answer: A
Chapter: 37
Q746:
Fill in the blank: The default method for passing arguments to functions in PHP is ______.
A. By reference
B. By value
C. By copy
D. By pointer
Correct Answer: B
Chapter: 37
Q747:
Fill in the blank: In PHP, the new keyword is used to create a ______.
A. Function
B. Variable
C. Object
D. None of the above
Correct Answer: C
Chapter: 37
Q748:
Fill in the blank: PHP's support for databases is implemented through _____.
A. ODBC
B. REST
C. GraphQL
D. SOAP
Correct Answer: A
Chapter: 37
Q749:
What will the following PHP code output? $conn=odbc_connect('northwind','','');
A. An object
B. A resource
C. A database connection
D. An error
Correct Answer: C
Chapter: 38
Q750:
What is the purpose of the <script> tag in JavaScript?
A. To style HTML elements
B. To interpret JavaScript content
C. To link CSS styles
D. To create a database query
Correct Answer: B
Chapter: 38
Q751:
Where should JavaScript code be placed for execution when the page loads?
A. In the <head> element
B. In the <body> element
C. Inside an external CSS file
D. In a <footer> element
Correct Answer: B
Chapter: 38
Q752:
JavaScript statements are terminated by:
A. Commas
B. Semicolons
C. Colons
D. Periods
Correct Answer: B
Chapter: 38
Q753:
JavaScript is considered a:
A. Strongly typed language
B. Weekly typed language
C. Compiled language
D. Assembly language
Correct Answer: B
Chapter: 38
Q754:
What type of operator is + in JavaScript?
A. Arithmetic
B. Comparison
C. Logical
D. String
Correct Answer: D
Chapter: 38
Q755:
Arrays in JavaScript are:
A. 1-based
B. 0-based
C. Dynamically typed
D. Immutable
Correct Answer: B
Chapter: 38
Q756:
What is the result of the expression var x = "10" - 2; in JavaScript?
A. Error
B. 8
C. "102"
D. 2
Correct Answer: B
Chapter: 38
Q757:
Which of the following is a logical operator in JavaScript?
A. &
B. &&
C. !=
D. ===
Correct Answer: B
Chapter: 38
Q758:
Arrays in JavaScript can hold:
A. Only numbers
B. Only strings
C. Any data type
D. Only booleans
Correct Answer: C
Chapter: 38
Q759:
What does the typeof operator in JavaScript return?
A. The data type of a variable
B. The memory address of a variable
C. The size of a variable
D. The name of the variable
Correct Answer: A
Chapter: 38
Q760:
What is the purpose of the break statement in JavaScript?
A. To skip the current iteration
B. To exit a loop or switch block
C. To continue to the next iteration
D. To define a function
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Modern Programming Languages

🚀 Start Quiz Now