levo

Exception Handling and Managing Input and Output

Checked and unchecked exceptions

  • 3 things to know
  • AS Unit 1

Overview

The distinction the compiler enforces, which faults must be caught or declared, which are left to the programmer, and why an unchecked exception usually signals a fault in the code rather than in the input.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is a checked exception?

Key term

Why are file operations made checked?

Key term

In Java, why are exceptions caused by programming mistakes left unchecked?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a checked exception?

    Model answer

    A checked exception is one the compiler insists is dealt with, so any method that might throw it must either catch it or declare it in a throws clause.

  2. 2

    What is an unchecked exception?

    Model answer

    An unchecked exception is one the compiler does not require to be handled, and it usually signals a programming mistake such as a bad index or a reference holding null.

  3. 3

    Give two examples of checked exceptions.

    Model answer

    A file not found exception and a general input or output exception are both checked, because no program can guarantee that a file exists or that a device will respond.

  4. 4

    Give two examples of unchecked exceptions.

    Model answer

    A null pointer exception and an array index out of bounds exception are both unchecked, because correct code should never produce either of them.

  5. 5

    Why are file operations made checked?

    Model answer

    The success of a file operation depends on the machine outside the program, so the language obliges the programmer to state what should happen when the file is missing, locked or unreadable.

  6. 6

    Why are programming mistakes left unchecked?

    Model answer

    Demanding a handler for every possible bad index would clutter almost every line of code, and the proper response to a programming mistake is to correct the code rather than to catch the fault.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Exception Handling and Managing Input and Output, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.