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
0Activity
0 of .
Results for:
No results containing your search query
P. 1
1-6-Polymorphism

1-6-Polymorphism

Ratings: (0)|Views: 63|Likes:
Published by Arsalan Ahmed
Polymorphism
Polymorphism

More info:

Published by: Arsalan Ahmed on Dec 26, 2012
Copyright:Attribution Non-commercial

Availability:

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

12/26/2012

pdf

text

original

 
1
Polymorphism
PolymorphismAbstract ClassesInterfaces
OOAD 1998/99Claudia
Niederée, Joachim W. SchmidtSoftware Systems Institute
c.niederee@tu-harburg.de http://www.sts.tu-harburg.de
OOAD98/99-STS-Polymorphism2
Polymorphism
“Substitutability“= You may use a subclass object wherever a base classobject is expecteddraw()erase()ShapeA CircleA SqareA Line
 
2
OOAD98/99-STS-Polymorphism3
“Extensibility“draw()erase()ShapeA CircleA SqareA LineA Triangle
OOAD98/99-STS-Polymorphism4
A problem?
Shape s =
new
Circle();Shapedraw()erase()SquareLineCircledraw()erase()draw()erase()draw()erase()
You might think
s.draw()
calls this
draw()
since
s
is a
Shape
We want it to callthis
draw()
since
s
actually points to a
Circle
 
3
OOAD98/99-STS-Polymorphism5
Early Function Call Binding
Function callFunction callFunction callfunctionbody
 a d d r e s s
  a  d  d  r  e  s  s
OOAD98/99-STS-Polymorphism6
Dynamic Binding in Java
Java method callJava method callJava method callCircle
draw()
Sqare
draw()
Line
draw()
DynamicBindingMechanism

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)//-->