Java Reference
In-Depth Information
Summary of Key Concepts
The heart of object-oriented programming is defining classes that represent
objects with well-defined state and behavior.
The scope of a variable, which determines where it can be referenced,
depends on where it is declared.
A UML class diagram helps us visualize the contents of and relationships
among the classes of a program.
An object should be encapsulated, guarding its data from inappropriate
access.
Instance variables should be declared with private visibility to promote
encapsulation.
Most objects contain accessor and mutator methods to allow the client to
manage data in a controlled manner.
The value returned from a method must be consistent with the return type
specified in the method header.
When a method is called, the actual parameters are copied into the formal
parameters.
A variable declared in a method is local to that method and cannot be
used outside of it.
A constructor cannot have any return type, even void .
A GUI is made up of components, events that represent user actions, and
listeners that respond to those events.
Listeners are often defined as inner classes because of the intimate relation-
ship between the listener and the GUI components.
Exercises
Visit www.myprogramminglab.com to complete many of these Exercises
online and get instant feedback.
EX 4.1
For each of the following pairs, which represents a class and
which represents an object of that class?
a. Superhero, Superman
b. Justin, Person
c. Rover, Pet
d. Magazine, Time
e. Christmas, Holiday
Search WWH ::




Custom Search