This module discussed some of Java's advanced object-oriented features, including interfaces, packages, and access control. In particular, you learned about the keywords:
- package
- import
- interface
- implements
- public
- protected
- private
You also learned that even though Java manages the memory, you can request that it perform certain tasks, such as garbage collection.
While you cannot free memory directly, you can ask the Java runtime to do it for you.
Before we delve deeper into the advantages of OO development, let us consider a more fundamental question:
What exactly is an object?
This is both a complex and a simple question and is complex because learning any method of
software development is not trivial.
It is simple because people already think in terms of objects.
For example, when you look at a person, you see the person as an object and an object is defined by two terms:
- attributes and
- behaviors.
A person has attributes, such as eye color, age, and height. A person also has behaviors, such as walking, talking, breathing, and reading text.
In its basic definition, an object is an entity that contains both data and behavior. The word
both is the key difference between OO programming and other programming methodologies.
In procedural programming, for example, code is placed into totally distinct functions or procedures. In a procedural language procedures become "black boxes", where inputs go in and outputs come out.
Data is placed into separate structures and is manipulated by these functions or procedures.