Monday, November 26, 2007

Java Notes


Chapter 1 Objectives
After you have read and studied this chapter, you should be able to
Name the basic components of object-oriented programming.
Differentiate classes and objects.
Differentiate class and instance methods.
Differentiate class and instance data values.
Draw object diagrams using icons for classes, objects, and other components of object-oriented programming.
Describe the significance of inheritance in object-oriented programs.
Name and explain the stages of the software life cycle.
Classes and Objects
Object
An object is a thing, both tangible and intangible. Account, Vehicle, Employee, etc
Class
To create an object inside the computer program, we must provide a definition for an objects' behavior and the information it maintains
This definition is termed a class
Instance
An object is called an instance of a class. or instantiates the class
Graphical Representation of an Object
Graphical Representation of a Class
Instance-of Relationship
Messages and Methods
To instruct a class or an object to perform a task, we send a message to it.
You can send a message only to the classes and objects that understand the message you sent to them.
A class or an object must possess a matching method to be able to handle the received message.
A method defined for a class is called a class method, and a method defined for an object is called an instance method.
A value we pass to an object when sending a message is called an argument of the message.
Sending a Message
Sending a Message and Getting an Answer
Calling a Class Method
Summary of Class and Object Icons
Class and Instance Data Values
An object is comprised of data values and methods.
An instance data value is used to maintain information specific to individual instances. For example, each Account object maintains its balance.
A class data value is used to maintain information shared by all instances or aggregate information about the instances.
For example, minimum balance is the information shared by all Account objects, whereas the average balance of all Account objects is an aggregate information.
Sample Instance Data Value
Sample Class Data Value
Variable and Constant Data Values
There are two types of data values:
Inheritance
Object-oriented programming, employs a mechanism called inheritance to design two or more entities that are different but share many common features.
First we define a class that contains the common features of the entities.
Then we define classes as an extension of the common class inheriting everything from the common class.
We call the common class the superclass and all classes that inherit from it subclasses. We also call the superclass an ancestor and the subclass a descendant.
Software Engineering and Software Life Cycle
The sequence of stages from conception to operation of a program is called software life cycle. Five stages are
Analysis
Design
Coding
Testing
Operation and Maintenance
Software engineering is the application of a systematic and disciplined approach to the development, testing, and maintenance of a program.
Having Fun with JavaSee the FunTime source
Object Diagram for FunTime
Execution Flow of the FunTime Program

0 comments: