Table of Contents |
Author's Note: This lesson on using Java's object features is very preliminary. It is likely that much of this lesson will change significantly in structure, organization and content. Also, there are many partially written sections, either missing or poor transitions, and many missing pages. Please bear with us.
In the lesson titled Object-Oriented Programming Concepts: A Primer you learned the concepts behind object-oriented programming. Now that you have an abstract understanding of object-oriented programming, it's time to get to work and put those concepts to practical use. This lesson shows you how to use and abuse the object-oriented paradigms of the Java language.In this lesson, you will learn how to create and destroy objects, how to create and subclass classes, and how to write methods. This lesson covers everything including how to protect the innards of an object from groups of other objects, override methods, create class templates using abstract classes and methods,
The Life Cycle of an Object
An object is a software module that has state and behaviour. An object's state is contained within its variables and its behaviour is implemented through its methods. The typical life-cycle of an object is 1) creation, 2) use, and 3) destruction. After an object has been created, any other object (that has access) can use its methods, or, inspect its variables. An object remains "alive" until no other objects are using it. Once an object has completed its useful life, you don't have to do anything--the Java runtime system will clean it up for you!Click on one of the links below for more information about each stage of an object's life:
Creating Your Own Class
A Java object is an instance of a class. Frequently, we say that an object's class is the object's type. The Java development environment comes with many classes that you can use in your programs. Or you can write your own. This section shows you how to write your own class including how to declare a class, declare its variables, and write its methods.Interfaces
Table of Contents |