Explore topic-wise MCQs in Php.

This section includes 19 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following is/are an exception?1. OutOfBoundException2. OutOfRangeException3. OverflowException4. UnderflowException

A. ll of the mentioned
B. and 3
C. and 2
D. one of the mentioned
Answer» B. and 3
2.

Which of the following is/are not an exception?1. BadFunctionCallException2. BadMethodCallException3. LogicException4. DomainException

A. ll of the mentioned
B. nly 4
C. and 4
D. one of the mentioned
Answer» E.
3.

What does SPL stand for?

A. tandard PHP Library
B. ource PHP Library
C. tandard PHP List
D. ource PHP List
Answer» B. ource PHP Library
4.

*$_Which of the following is/are an exception?1. OutOfBoundException2. OutOfRangeException3. OverflowException4. UnderflowException?

A. All of the mentioned
B. 1 and 3
C. 1 and 2
D. None of the mentioned
Answer» B. 1 and 3
5.

*$_Which function is responsible for sending a custom message to the system log??

A. systemlog()
B. syslog()
C. log_system()
D. sys_log()
Answer» C. log_system()
6.

*$_Which one of the following is the right description for the method getMessage() ??

A. Returns the message if it is passed to the constructor
B. Returns the message if it is passed to the class
C. Returns the message if it is passed to the file
D. Returns the message if it is passed to the object
Answer» B. Returns the message if it is passed to the class
7.

*/*_Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use??

A. error_reporting = E_ALL
B. error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
C. error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
D. error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR
Answer» E.
8.

_ Which of the following is/are not an exception?1. BadFunctionCallException2. BadMethodCallException3. LogicException4. DomainException$?

A. All of the mentioned
B. Only 4
C. 3 and 4
D. None of the mentioned
Answer» E.
9.

_ Which logging option’s description is, if an error occurs when writing to the syslog, send output to the system console?$?

A. LOG_CONS
B. LOG_NDELAY
C. LOG_ODELAY
D. LOG_PERROR
Answer» B. LOG_NDELAY
10.

_ Which of the following statements invoke the exception class?$?

A. throws new Exception();
B. throw new Exception();
C. new Exception();
D. new throws Exception();
Answer» C. new Exception();
11.

_ Which character do the error_reporting directive use to represent the logical operator NOT?$?

A. /
B. !
C. ~
D. ^
Answer» D. ^
12.

_How many predefined exceptions does SPL provide access to?$?

A. 13
B. 14
C. 15
D. 16
Answer» B. 14
13.

_Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog() functions?$?

A. define_variable()
B. define_log_variable()
C. log_variable()
D. define_syslog_variable()
Answer» E.
14.

_Which version added the method getPrevious()?$?

A. PHP 4
B. PHP 5
C. PHP 5.1
D. PHP 5.3
Answer» E.
15.

Which version of PHP introduced E_STRICT Error level?$?

A. PHP 4
B. PHP 5
C. PHP 5.2
D. PHP 5.3
Answer» C. PHP 5.2
16.

What does SPL stand for??

A. Standard PHP Library
B. Source PHP Library
C. Standard PHP List
D. Source PHP List
Answer» B. Source PHP Library
17.

Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line??

A. ignore_repeated_errors
B. ignore_repeat_error
C. repeatedly_ignore_error
D. repeated_error_ignore
Answer» B. ignore_repeat_error
18.

How many methods are available for the exception class??

A. 5
B. 6
C. 7
D. 8
Answer» D. 8
19.

Which version of PHP was added with Exception handling?

A. PHP 4
B. PHP 5
C. PHP 5.3
D. PHP 6
Answer» C. PHP 5.3