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
The try and catch block
- 3 things to know
- AS Unit 1
Overview
Enclosing the statements that may fail, what happens to the rest of the block once an exception is thrown, catching by type, and what a handler should do besides reporting.
What you need to know
Answer each one before you reveal it.
What happens when the statements in a try block all succeed?
Why must a variable that is used after a try block be declared before it?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What goes inside a try block?
Model answer
A try block holds the statements that might fail, grouped together so that a fault in any of them can be dealt with in one place.
- 2
What goes inside a catch block?
Model answer
A catch block holds the code that responds to a fault, and its heading names the type of exception it will handle and a variable through which the exception object can be read.
- 3
Write out the general shape of a try and catch in Java.
Model answer
The construct is written try, then the statements that might fail in braces, then catch with an exception type and a variable in brackets, then the statements that handle the fault in braces.
- 4
What happens to the rest of a try block once an exception is thrown part way through it?
Model answer
The remaining statements of the try block are abandoned at once and control passes to the matching catch block, so no later statement inside the try is executed.
- 5
A program runs try { System.out.println("A"); int x = 5 / 0; System.out.println("B"); } catch (ArithmeticException e) { System.out.println("C"); } and then System.out.println("D");. What is printed?
Model answer
The letter A is printed, then the division by zero throws before B can run, so control jumps to the handler and prints C, and execution continues after the block to print D, giving A, C and D.
- 6
What happens when the statements in a try block all succeed?
Model answer
The whole try block runs, every catch block is skipped, and execution continues at the first statement after the construct.
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.