Java Exception Handling - Exceptions Types
An exception (extends java.lang.Exception) defines an unusual or erroneous situation that
must either be handled by the programmer or declared in a throws clause. e.g. IOException.
A runtime/unchecked exception (
Part B: Short Answer (12 marks 4 x 3)
Answers to these questions are expected to be between one and five sentences long.
Components cannot be added directly to a JFrame. What portion of the JFrame needs to be
retrieved to add components? How is this do
Creating an Exception Type
To create a custom exception type, we can simply extend the appropriate
subclass of the Exception hierarchy, and inherit the properties that make it
usable as an exception.
For example, if our custom exception was to model a pro
The throws Clause
The throws clause specifies that
(1)Exceptions are not going to be handled in the method where they are generated, and
(2) That they should be thrown to the calling method.
This has been used in programming 1:
public static void main(Str
In general, development consists of three broad activities
These can be further subdivided but conceptually activities generally fall into one of
these broader categories
Analysis (e.g. OOA)
understanding and defining the pr
As we have seen object-oriented programming is based on a number of objects working
together to perform a function.
This kind of approach to developing code can give a number of benefits, such as easier
code maintenance and enhanced
System Structure - Discovering Classes and Relationships
Classes are often either a concrete entity (a student, or a course), or an abstract concept (a
shape, or form of transport.)
A good rule of thumb for discovering classes is to look for nouns in the
Question Set #2 - Questions
Whenever nodes of a linked list need to be manipulated, the latter references are modified
before the earlier ones. What is the main reason for doing so?
a) It is an IEEE standard for a linked list to work that way.
Part B: Short Answer (5 marks 4 x 3)
(key items in each answer are italicised)
6. The content pane of the JFrame needs to be retrieved. This is done by calling the
7. It is named such because it natively (and most efficiently) fac
Question Sheet #3 - Questions
Heavyweight user interface components are:
a) Inefficiently implemented.
b) Those which rely on the corresponding native peer component.
c) Those which provide a large amount of functionality.
d) None of the above.
The constructor is a special method that is invoked to create a new object. Its
purpose is to initialise the object (including its instance variables) to a known
The constructor has the same name as the class. It is always invoked w