PRACTICE • LEARN • GROW
Module 9 Final Quiz: Error Handling MCQs
Solve topic-wise placement questions and improve your skills.
Module 9 Final Quiz: Error Handling Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What is the purpose of the
finally block in a try-catch construct?
A.
It executes only if an error was caught
B.
It executes unconditionally, whether an error occurred or the try block succeeded completely
C.
It suppresses any uncaught exceptions
D.
It executes only if no error occurred
Explanation & Key
Correct Answer:
2
What will be printed to the console?
function test() {
try {
return 'try';
} finally {
console.log('finally');
}
}
console.log(test());
A.
'try'
B.
'finally' followed by 'try'
C.
'try' followed by 'finally'
D.
'finally'
Explanation & Key
Correct Answer:
3
What happens when you execute
JSON.parse('invalid json') without a try/catch block?
A.
It returns null
B.
It throws a SyntaxError and crashes script execution if uncaught
C.
It returns undefined
D.
It retries parsing
Explanation & Key
Correct Answer:
4
What are the standard properties present on a standard JavaScript
Error object instance?
A.
status, code, data
B.
name, message, and stack
C.
type, detail, timestamp
D.
id, error, traceback
Explanation & Key
Correct Answer:
5
What keyword is used to raise an exception manually in JavaScript?
A.
raise
B.
throw
C.
reject
D.
emit
Explanation & Key
Correct Answer:
6
How do you create a custom Error class in modern JavaScript?
A.
class MyError extends Object {}
B.
class MyError extends Error { constructor(msg) { super(msg); this.name = 'MyError'; } }
C.
function MyError() { return Error; }
D.
class MyError implements Exception {}
Explanation & Key
Correct Answer:
7
What will happen in this nested try-catch snippet?
try {
try {
throw new Error('Inner');
} finally {
console.log('F1');
}
} catch(e) {
console.log(e.message);
}
A.
'Inner' 'F1'
B.
'F1' 'Inner'
C.
'F1'
D.
Unhandled Exception
Explanation & Key
Correct Answer:
8
Can you throw primitive values like strings or numbers using
throw in JavaScript?
A.
No, only instances of Error can be thrown
B.
Yes, JavaScript allows throwing any value (e.g. throw 'Oops' or throw 404), although throwing an Error instance is best practice
C.
Only numbers can be thrown
D.
Only booleans can be thrown
Explanation & Key
Correct Answer:
9
What is re-throwing an error?
A.
Throwing an error inside a loop
B.
Catching an error, inspecting or logging it, and using 'throw err' to let outer handlers or callers manage it
C.
Converting an error to a string
D.
Clearing an error
Explanation & Key
Correct Answer:
10
How does optional catch binding (ES2019) simplify error handling when the error object is unneeded?
A.
It allows writing
try { ... } catch { ... } without declaring (err)
B.
It makes catch optional in a try-finally block
C.
It auto-retries the try block
D.
It turns errors into warnings
Explanation & Key
Correct Answer:
11
What is an UnhandledPromiseRejection?
A.
A rejected promise that has no attached .catch() handler or await try/catch block
B.
A resolved promise with null data
C.
A syntax error in an arrow function
D.
A memory leak in Node.js
Explanation & Key
Correct Answer:
12
What will be printed?
try {
throw new TypeError('Invalid Type');
} catch(err) {
console.log(err instanceof Error, err instanceof TypeError);
}
A.
true false
B.
true true
C.
false true
D.
false false
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong