Technical University of Denmark DTU
02115   Java Programming
Autumn 2011

Week plan #2

For the week   5. September - 9. September


The Java knowledge of the audience

At the lectures last Tuesday we have the intentions to find out about your current Java knowledge. But our questioning was not precise enough.
The technical level of the course will be as stated in the official course description and at the subpage   Course goals
But after working with the subjects from the PS textbook as stated below in the section After the lectures you will be convinced that the course is on a level higher than just introductory.

I much appreciate to have received exercise suggestions by e-mail, but those exercises were unfortunately better suited for a course on Algorithms and data structures. This week the exercises are grouped on different levels by an or



Preparations for the week

Last week we saw how to make new objects composed of other objects, primarily in the clock example, where a ClockDisplay-object is made up of two NumberDisplay-objects and a String-object. On pages 68-70 of BK we can see how that is achieved: On Figure 3.4 of BK (page 71) the relations between the objects are shown - the displayString and it's reference to a String-object holding the value "15:23" has been left out.

Actually, when experimenting with the lab-classes and the mail-system projects, we can figure out that behind the scene a LabClass-object and a MailServer-object must hold fields which refer to flexible object structures capable of holding arbitrary numbers of Student-objects and MailItem-objects, respectively.

This week projects using flexible object structures like lists, sets and maps are introduced. The PS textbook gives an overview of the available structures on page 92. Take a look, but skip syntactic details like List<T>, Set<T> and Map<K,V> and on the figure don't worry about interfaces and abstract classes. Focus on the structure and on the Concrete classes of which BK in the Chapters 4 and 5 introduces the ArrayList<T>, the HashMap<K,V> and the HashSet<T>. The general applicable class types T, K and V are all substituted with class String in the Chapter 4 and 5 BlueJ projects of BK.


Before going on with the BK textbook I presume that you have done what has been stated in Week plan #1.

As a minimal preparation to this week study the Chapters 4 and 5 of BK to the following extent:

  1. Chapter 4: 4.1 - 4.6 and 4.12.2 - 4.12.4; pages 87-94 and 117-119:
  2. Chapter 5: 5.1 - 5.3.1, 5.5 - 5.6.2 and 5.7; pages 128-138, 146-149 and 152-153:


The lectures

We will cover selected parts of the textbooks, primarily the following parts of BK
  - Chapter 4, pages 87-123
  - Chapter 5, pages 128-165



Exercises at the PC's

In case you end up in a state of a locked terminal session you have to kill the session by holding [CTRL] and [ALT] pressed down and in that state press [BACKSPACE] twice.
Unsaved work is lost, but afterwards a normal logon is possible.


Exercises are taken solely from the BK textbook. The exercises are grouped by use of or. Choose a group matching your interests and your present Java experience:

After the lectures

The lectures has not covered all details of the chapters 4 and 5 of BK. Work through the missing parts and do the exercises missed at the exercise class, refer to the section above, with the supplements mentioned below as a minimum.
If you would like to exercise the use of ArrayList's in a more creative way, then do Exercises 4.25-4.27 and 4.34-4.40.

At the end of this week you are supposed to be familiar with the following parts of the BK textbook:


The consequences of applying the keywords static and final as introduced in section 5.13 can be summarised as follows:

 Keyword  Concept Description
 final (without static)  instance constant  Every object (instance) has it's own constant
 static (without final)  class variable  All objects share one common variable (field)
 static final  class constant  All objects share one common constant


In the PS textbook read the following sections:
Jens Thyge Kristensen, Email: jtk@imm.dtu.dk

Newest edition:   1. September (the section 'The Java knowledge of the audience' has been added)
Previous editions:
    - 30. August
    -   8. April (a skeleton only)