Java Reference
In-Depth Information
of $18.25 per hour as a carpenter, is an object of the class
WageEarningEmployee. The class contains data elements for storing the
name and address, hourly wage, number of hours worked, number of de-
pendents, and all other information necessary for managing the payroll. In
addition, the class WageEarningEmployee also contains programming
routines (called methods ) for calculating wages, paying taxes, printing
checks, and performing other necessary data manipulations. Other
classes of the payroll software system may be called SalariedEmployee,
AdministrativeStaff, and Executives. Each class would hold the data and
processing elements necessary for each employee type.
Programmers note:
As an object-oriented language, Java resembles Smalltalk. Smalltalk
was developed at the Xerox Palo Alto Research Center (PARC) and
first released in 1980. Although Smalltalk has never been very popu-
lar, it is considered a model for object-oriented programming lan-
guages. Java supports inheritance, encapsulation, and polymorphis,
the cornerstones of object-oriented systems.
Java is strongly-typed
Java is described as a strongly-typed language. This means that all data
must belong to a specific type and that the data type cannot be changed
whiletheprogramisexecuting.Forexample,wholenumbersbelongtoone
data type and fractional numbers to another one.
To understand the notion of a strongly-typed language you can imagine
a data type named int, that is intended for storing integer (whole) num-
bers, and another type named float, designed for storing fractional num-
bers. (It just happens that the int and float data types actually exist in
Java.) In this language, we could use the int type to store the number of
dependents of an employee since this value would always be a whole
number; while the employee's hourly wage, which could be a fraction,
would be stored in a type float. Now suppose that an employee, for tax
purposes, wanted to claim a fractional number of dependents, say 2.5. If
the language is strongly-typed it would not be possible to store a frac-
tional number in a data element of int type. A weakly-typed language, on
the other hand, would allow storing a fractional number in an integer data
type. Java is defined as strongly-typed because each data element must be
consistent with the type of the data container that holds it. Strongly typed
languages are said to be more reliable.
Search WWH ::




Custom Search