Chapter 5
Most of the information on this and other chapters refers
directly to material in Wilson, L.B. and Clark, R.G.,
Comparative Programming Languages (Third Edition, updated by R.G. Clark),
Addison-Wesley, September 2000, ISBN 0-201-71012-9.
The material is intended to supplement the textbook by providing
further examples and discussion.
It is not self-standing, but assumes that you have a copy of the book to hand.
Supplementary Questions
-
The book contains the definition of a Java BankAccount class
and the equivalent structure in Pascal.
Outline a Pascal type definition and associated operations
corresponding to the following Java class.
class Person {
String name;
int age;
public Person(String n, int a) {
name = n; age = a;
} // constructor
public int getAge() {
return age;
} // getAge
public void haveBirthday() {
age = age + 1;
} // haveBirthday
} // Person
-
Two features of object-oriented programming are information hiding
and encapsulation.
What is meant by this?
In what way does the Pascal code in the BankAccount
example not support information hiding?
What aspect of encapsulation does it support and what aspect does it
not support?
-
How does Ada solve the information hiding and encapsulation
problems identified in the Pascal example?
Object-oriented languages
-
Pages 118-119 give an outline Java listing.
A full listing is
available.
WindowListener is a Java Interface (see page 205).
As we are implementing the WindowListener Interface,
we need to provide implementations for all its abstract methods.