Escolar Documentos
Profissional Documentos
Cultura Documentos
Chapter 5
Code Management
Object Oriented Programming provides better way to manage code, so one can
build and maintain application of any size and complexity using object oriented concepts.
An application could be built in several ways.
An application may be a collection of several objects.
Object itself may contain other objects
Object may be created from existing objects
Several objects may be using same interface for doing same thing or different
thing.
Code management in java can be accomplished through inheritance, composition,
and polymorphism.
Object class
All java class has single rooted class hierarchy that starts from java.lang.Object.
The class you create has one implicit parent, Object if your class was not explicitly sub-
classed.
class Stock{
private int stock;
public Stock(int stock){
this.stock=stock;
}
}
class Stock{
private int stock;
public Stock(int stock){
this.stock=stock;
}
}
tURBOPLUS
Code Management
tURBOPLUS
Code Management
The above program shows dynamic method dispatch, where shapes[i].draw() will be
solved only at run-time.
tURBOPLUS