Error Handling MCQ Questions - C Programming

This section focuses on the "Error Handling" in C programming. These Multiple Choice Questions (MCQ) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. Error handling refers to the practice of ____________ that occur during the execution of a program.

A. detecting runtime errors
B. reporting runtime errors
C. handling runtime errors
D. All of the above

View Answer


2.  When a function is called in C, a variable named as ___________ is automatically assigned a code (value) which can be used to identify the type of error that has been encountered.

A. perror
B. errno
C. strerror
D. exit_failure

View Answer


3. Which of the following returns a pointer to the textual representation of the current errno value?

A. perror
B. errno
C. strerror
D. None of the above

View Answer


4. perror displays the string you pass to it, followed by a colon, a space, and then the textual representation of the current errno value.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


5. Which of the following is a common technique for error handling in C Programming Language?

A. Using global variables
B. Using try-catch blocks
C. Using exceptions
D. All of the above

View Answer


6. Within main, return expr statement is equivalent to ________

A. abort(expr)
B. exit(expr)
C. ferror(expr)
D. None of the above

View Answer


7. Which of the following is an example of a runtime error in C Programming?

A. Syntax error
B. Compiler error
C. Divide by zero
D. None of the above

View Answer


8. To detect and handle runtime errors is the purpose of error handling in C.

A. Yes
B. No
C. Can be yes or no
D. Can not say

View Answer


9. In C programming language, what does a function return when it encounters an error?

A. A null pointer
B. A warning message
C. An error code
D. All of the above

View Answer


10. stderr is similar to?

A. stdin
B. stdout
C. Both stdout and stdin
D. None of the above

View Answer






Discussion



* You must be logged in to add comment.