Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Can you throw and catch non-error objects, like strings, in JavaScript?

View

What will happen if an error is thrown inside the catch block?

View

How do you nest multiple try/catch blocks in JavaScript?

View

In a try/catch block, where does control go if an error is thrown?

View

What is the purpose of a finally block?

View

Is it possible to rethrow an error inside the catch block?

View

How do you access the error object in the catch block?

View

What type of error does JSON.parse() throw if it encounters invalid JSON data?

View

Which of the following correctly handles an error from an asynchronous function?

View

Which of the following errors is not catchable using try/catch?

View

Can you throw and catch non-error objects, like strings, in JavaScript?

Yes
No
Only in strict mode
Only in modern browsers

What will happen if an error is thrown inside the catch block?

The program terminates
The error is ignored
The error propagates to the next outer try/catch block
The finally block executes

How do you nest multiple try/catch blocks in JavaScript?

It’s not possible
By placing one try block inside another try or catch block
By using the nested keyword
Only one try/catch block is allowed per function

In a try/catch block, where does control go if an error is thrown?

It goes back to the start of the try block
It skips the rest of the try block and goes to the catch block
It continues execution from the throw statement
It stops the entire program

What is the purpose of a finally block?

To ensure that code runs regardless of success or failure in the try block
To catch any missed errors
To prevent the catch block from running
To terminate the program

Is it possible to rethrow an error inside the catch block?

Yes
No
Only in modern JavaScript
Only if you create a new error object

How do you access the error object in the catch block?

It’s automatically available in the catch block
You must declare the error object before the try block
The error object is passed as an argument to the catch block
You cannot access the error object

What type of error does JSON.parse() throw if it encounters invalid JSON data?

SyntaxError
TypeError
RangeError
ReferenceError

Which of the following correctly handles an error from an asynchronous function?

Use a try/catch block inside the asynchronous function
Use a throw statement inside await
Use the catch method with a promise
Both a and c

Which of the following errors is not catchable using try/catch?

ReferenceError
SyntaxError
TypeError
System-level errors like a browser crash