Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
Object Oriented Design Implementation

Object Oriented Design Implementation

Ratings: (0)|Views: 672|Likes:
Published by api-3844983
maping ood to java language
maping ood to java language

More info:

Published by: api-3844983 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Object Oriented Design Implementation
Chapter
3
Object Oriented Design Implementation
To implement object oriented design java provides number of keywords that are
integral part of base language system.
classand interface are two key words used to implement abstraction about an
object.

For e.g. considercu rren cy object. Government of different country use currency
of various denominations. However one can observe information like denomination
value, the bank responsible to issue the currency are present on the all currency. Then,
how to abstract that information? Below is the abstraction of currency for our example
purpose.class Currency{

private String country;
private String bank;
private String value;

}

However, object orientation is not simply grouping up of properties. For e.g. if
you want know which bank is issuing US currency? You may ask about this to your
friend. If it is so, above described currency class object should be capable to answer to
your question. Let us modify the class to include that feature.

class Currency{
private String country;
private String bank;
private String value;

public String getBankInfo(){
return bank;
tURBOPLUS
Object Oriented Design Implementation
}
public void setBankInfo(String bank){
this.bank=bank;
}
}
Anatomy of a java class
class AJavaClass{
---------
---------
---------
AJavaClass(){}
aJavaMethod(){
--------
--------
}aJavaMethod(int x){}
}Instance variable
Exists when object instantiated. Each object has its own copy.
Class variable (Static variable).
Exists with class. All objects share.
Local variable.
Exits when the method being called.
Static method
tURBOPLUS
Instance
variable/static
(c la s s )v a r ia b le
Static/non-static
m e th o d s
Local variable
Clss name
Constructor
m e th o d
Overloaded
m e th o d
Object Oriented Design Implementation
Does not require object reference to invoke.
Non-static method
Requires object reference to invoke
Constructor Method
A method having the name of class
Overloaded method
Constructor method/static or non-static method can not be differentiated by their
name but from their parameter count or parameter type.
Constructor
\u2022
Constructor or constructor method ensures its execution before executing any
other method.
\u2022
Constructor will be called at the time of object instantiation.
\u2022
Constructor also provide a pattern that determines how an object will be created
\u2022
Constructor is the best place where one can place some code that has to be
executed before executing any other methods.
Object Life Cycle
The following figure illustrate life cycle of a java class that consists of static block
and constructor.
Object Life Cycle
tURBOPLUS
AnObject.class
Instance of
AnOb
j
ect.cl
Executes
construct
Garbag
e
No
reference
Class
Loader
Executes static
block

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
Anand Jeenkeri liked this
aporat liked this
Brian King liked this
Naheed Nishan liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->