CCEA A-Level Software Systems Development CL4
Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures
Exception Handling and Managing Input and Output
Testing an Object Oriented Application
Graphical User Interface Objects and Events
Multiple Forms and Linking to Files
Designing, Testing and Evaluating an Event Driven Application
Reasons for Systems Development and Systems Methodologies
Managing Projects
Testing Strategies
Database Concepts and Entity Relationship Modelling
Normalisation and Structured Query Language
Project Management and the Systems Approach in Practice
Defining Requirements and Documenting the Design
Building a Desktop Solution with a Database
Testing and Evaluating the Solution
Exception Handling and Managing Input and Output
Catching more than one kind of exception
- 3 things to know
- AS Unit 1
Overview
Several catch blocks against one try, why the order matters, why a general handler placed first makes the ones after it unreachable, and the finally block that runs either way.
What you need to know
Answer each one before you reveal it.
In what order are catch blocks considered?
How many catch blocks run for a single exception?
Questions from this subtopic
Each one with the model answer underneath.
- 1
Why might a single try block need several catch blocks?
Model answer
One group of statements can fail in more than one way, and each kind of fault may need a different response, so a separate catch block is written for each type.
- 2
In what order are catch blocks considered?
Model answer
Catch blocks are considered in the order they are written, and the first whose type matches the exception thrown is the one that runs.
- 3
How many catch blocks run for a single exception?
Model answer
Exactly one catch block runs, and control then passes to the code after the whole construct rather than to the remaining blocks.
- 4
Why must the most specific exception type be caught first?
Model answer
A handler for a general type also matches every specific type beneath it, so putting the general one first would intercept the specific faults and the later blocks could never be reached.
- 5
What does the compiler report if a general exception type is caught before a specific one?
Model answer
The compiler reports the later block as unreachable code, because no exception could ever arrive at it.
- 6
A try block may throw either a number format exception or an arithmetic exception, and the catch blocks are written in that order. Which runs when the user types the word five?
Model answer
The word five cannot be converted to a number, so a number format exception is thrown, the first handler runs and the arithmetic handler is skipped entirely.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
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.