Search Header Logo

Practice: Exception Handling

Authored by Wayground CTE

Information technology (IT)

9th Grade

Blooms Level: Apply covered

Practice: Exception Handling
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

16 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which keyword starts a block where code that might throw an error is placed?

Finally

Catch

Throw

Try

Answer explanation

The try block wraps risky code so any error it throws can be caught. Catch handles the error after try exits.

Tags

Blooms Level: Remember

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

When a developer uses `throw new Error('msg')`, what does the catch block parameter contain?

A boolean flag value

A numeric status code

An Error object instance

A raw stack trace string

Answer explanation

When an Error object is explicitly thrown, the catch parameter holds that Error object, giving access to properties like message and name. A stack trace string is just one property of the object, not the parameter itself.

Tags

Blooms Level: Remember

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

A developer needs cleanup code to run after a try block, even if catch also runs. Where does it go?

In a throw statement

In the try block

In the finally block

In the catch block

Answer explanation

Finally executes after try and catch complete, making it the right place for cleanup like closing files or resetting UI state.

Tags

Blooms Level: Apply

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which keyword raises a custom error from inside a function?

Catch

Error

Raise

Throw

Answer explanation

Throw signals an error and stops normal execution. Error is the constructor used with throw, not the keyword that raises it.

Tags

Blooms Level: Remember

5.

MULTIPLE SELECT QUESTION

2 mins • 2 pts

Which TWO statements about try-catch-finally are correct? (Select all that apply)

Try must be paired with catch, finally, or both

Throw can only appear inside a catch block

Catch only runs when an error is thrown

Errors thrown in try skip remaining try statements

Finally runs only when no error occurs

Answer explanation

Catch fires only on errors, and try requires at least one of catch or finally. Finally runs in both cases, and throw is allowed anywhere.

Tags

Blooms Level: Analyze

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

A function divides two numbers and may receive a string argument. Where should the conversion attempt be wrapped?

Inside a try block

Inside a throw statement

Inside a finally block

Inside a catch block

Answer explanation

Code that might fail belongs in try so any thrown error can be caught. Catch handles the failure after it occurs, not before.

Tags

Blooms Level: Apply

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What happens to code after a throw statement in the same try block?

It runs only if catch is absent

It runs normally afterward

It is skipped entirely

It runs after finally completes

Answer explanation

Throw immediately exits the current block, so later statements in try are skipped. Control jumps to the matching catch block.

Tags

Blooms Level: Understand

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?