1
1
Introduction to
object-oriented
Programming
1992-2007 Pearson Education, Inc. All rights reserved.
2
OBJECTIVES
In this chapter you will learn:
Basic object technology concepts, such as classes,
objects, attributes, behaviors, encapsulation,
inheritance and polymorphism.
A typical Java development environment.
Java's role in developing distributed client/server
applications for the Internet and the web.
The history of the UML—the industry-standard object-
oriented design language.
1992-2007 Pearson Education, Inc. All rights reserved.
3
1.1 Introduction
• Java Standard Edition (Java SE) 6
• Sun’s implementation called the Java Development Kit
(JDK)
• Object-Oriented Programming
• Java is language of choice for networked applications
• Java Enterprise Edition (Java EE) geared toward large-
scale distributed applications and web applications
• Java Micro Edition (Java ME) geared toward applications
for small, memory constrained devices
1992-2007 Pearson Education, Inc. All rights reserved.
4
1.2 Java Class Libraries
• Java programs consist of classes
– Include methods that perform tasks
• Return information after task completion
• Java provides class libraries
– Known as Java APIs (Application Programming
Interfaces)
• To use Java effectively, you must know
– Java programming language
– Extensive class libraries
1992-2007 Pearson Education, Inc. All rights reserved.
5
1.3 Typical Java Development
Environment
• Java programs go through five phases
– Edit
• Programmer writes program using an editor; stores program on disk with
the .java file name extension
– Compile
• Use javac (the Java compiler) to create bytecodes from source code program;
bytecodes stored in .class files
– Load
• Class loader reads bytecodes from .class files into memory
– Verify
• Bytecode verifier examines bytecodes to ensure that they are valid and do not
violate security restrictions
– Execute
• Java Virtual Machine (JVM) uses a combination of interpretation and just-
in-time compilation to translate bytecodes into machine language
1992-2007 Pearson Education, Inc. All rights reserved.
6
Fig. 1.1 | Typical Java development environment.
1992-2007 Pearson Education, Inc. All rights reserved.
7
1.4 Software Engineering Case Study: Introduction
to Object Technology and the UML (Required)
• Object orientation
• Unified Modeling Language (UML)
– Graphical language that uses common notation
– Allows developers to represent object-oriented designs
1992-2007 Pearson Education, Inc. All rights reserved.
8
1.4 Software Engineering Case Study
(Cont.)
• Objects
– Reusable software components that model real-world items
– Look all around you
• People, animals, plants, cars, etc.
– Attributes
• Size, shape, color, weight, etc.
– Behaviors
• Babies cry, crawl, sleep, etc.
1992-2007 Pearson Education, Inc. All rights reserved.
9
1.4 Software Engineering Case Study
(Cont.)
• Object-oriented design (OOD)
– Models software in terms similar to those used to describe real-
world objects
– Class relationships
– Inheritance relationships
– Models communication among objects
– Encapsulates attributes and operations (behaviors)
• Information hiding
• Communication through well-defined interfaces
• Object-oriented language
– Programming in object-oriented languages is called object-
oriented programming (OOP)
– Java
1992-2007 Pearson Education, Inc. All rights reserved.
10
1.4 Software Engineering Case Study
(Cont.)
• Associations
– Relationships between classes
• Packaging software in classes facilitates reuse
1992-2007 Pearson Education, Inc. All rights reserved.
11
1.4 Software Engineering Case Study
(Cont.)
• Object-Oriented Analysis and Design (OOA/D)
– Essential for large programs
– Analyze program requirements, then develop a design
– UML
• Unified Modeling Language
• Standard for designing object-oriented systems
1992-2007 Pearson Education, Inc. All rights reserved.
12
1.4 Software Engineering Case Study
(Cont.)
• UML
– Graphical representation scheme
– Enables developers to model object-oriented systems
– Flexible and extensible
1992-2007 Pearson Education, Inc. All rights reserved.