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.

Section 5.2 Procedural and object-oriented architecture

Supplementary Questions

  1. 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
    
  2. 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?
  3. How does Ada solve the information hiding and encapsulation problems identified in the Pascal example?

Section 5.3 Alternative programming architectures

Object-oriented languages