Object-Oriented Programming

dat1/inf1/sw3

Location

B3-104

Time

September 16, 10.15-12.00

Subject

This seminar covers the topics initialization and clean-up of objects. Many bugs in C programs are due to that variables have not been properly initialized. This problem is solved in object-oriented programming languages by adding a construct to the language called a constructor where the instance variables can be assigned reasonable start values. This way all the initialization happens in only one place. The opposite of initialization is clean-up. Java has an automatic main memory clean-up mechanism called a garbage collector. This means that clean-up in general is very simple in Java. However, note that the garbage collector only cleans up memory, it does not e.g., clean up connections to database or open files, these must be closed explicitly by the programmer.

Readings

"Thinking in Java" Chapter 4. You may skip the sections  "How a Garbage Collector Works" pp. 188-191 and  "Multidimensional Arrays" pp. 208-211.

Exercise

Exercise

Slides

PDF

Links

Introduction to Programming Using Java

The Java Tutorial: Object-Oriented Programming Concepts

Best regards,
Kristian Torp