Java Reference
In-Depth Information
C H A P T E R 2
Discovering Classes and Objects
Chapter1 gentlyintroducedyoutotheJavalanguagebyfocusingmainlyonfundamental
languagefeaturesrangingfromcommentstostatements.Usingonlythesefeatures,you
cancreatesimpleapplications(suchas HelloWorld andtheapplicationsmentionedin
thechapter'sexercises)thatarereminiscent ofthosewritteninstructuredprogramming
languages such as C.
Note Structured programming is a programming paradigm that enforces a logical
structure on programs through data structures (named aggregates of data items), func-
tions (named blocks of code that return values to the code that calls [passes program
execution to] them), and procedures (named blocks of code that don't return values
to their callers). Structured programs use sequence (one statement follows another
statement),selection/choice(if/switch),andrepetition/iteration(for/while/do)program-
ming constructs; use of the potentially harmful GOTO statement (see ht-
tp://en.wikipedia.org/wiki/GOTO ) is discouraged.
Structured programs separate data from behaviors. This separation makes it difficult
tomodelreal-worldentities(suchasabankaccountsandemployees)andoftenleadsto
maintenanceheadacheswhenprogramsbecomecomplex.Incontrast,classesandobjects
combinedataandbehaviorsintoprogramentities;programsbasedonclassesandobjects
are typically easier to understand and maintain.
Chapter2 takesyoudeeperintotheJavalanguagebyfocusingonitssupportforclasses
andobjects.Youfirstlearnhowtodeclareclassesandcreateobjectsfromtheseclasses,
andthenlearnhowtoencapsulatestateandbehaviorsintotheseprogramentitiesthrough
fields and methods. After learning about class and object initialization, you move bey-
ond this object-based programming model and dive into object-oriented programming ,
by exploring Java's inheritance- and polymorphism-oriented language features.
Search WWH ::




Custom Search