Lecture 01 - Introduction to Classes, Objects, Methods and Strings
Lecture 01 - Introduction to Classes, Objects, Methods and Strings
Introduction to
Classes, Objects,
Methods and
Strings
From the textbook
Java How to Program 11/e
Top Compartment
} In the UML, each class is modeled in a class diagram as a rectangle
with three compartments. The top one contains the class’s name
centered horizontally in boldface.
4 Account UML Class Diagram
Middle Compartment
} The middle compartment contains the class’s attributes, which
correspond to instance variables in Java.
Bottom Compartment
} The bottom compartment contains the class’s operations, which
correspond to methods and constructors in Java.
} The UML represents instance variables as an attribute name, followed
by a colon and the type.
} Private attributes are preceded by a minus sign (–) in the UML.
} The UML models operations by listing the operation name followed
by a set of parentheses.
} A plus sign (+) in front of the operation name indicates that the
operation is a public one in the UML (i.e., a public method in Java).
4 Account UML Class Diagram
Return Types
} The UML indicates an operation’s return type by placing a colon and
the return type after the parentheses following the operation name.
} UML class diagrams do not specify return types for operations that do
not return values.
} Declaring instance variables private is known as data hiding or
information hiding.
Parameters
} The UML models a parameter of an operation by listing the parameter
name, followed by a colon and the parameter type between the
parentheses after the operation name
5 Additional Notes on Class AccountTest