Professional Documents
Culture Documents
Lecture Objectives
p instanceof BoxShape
Polymorphism (Cont’d)
double m = x.getMeasure();
Continued…
Polymorphism (Cont’d)
• Called late binding: resolved at runtime
Figure f;
Box b = new Box(1, 4, 4);
f = b;
f.drawAt(2);
Triangle t = new Triangle(1,2);
f = t;
f.drawAt(2);
Dynamic Binding (Cont’d)
• Example:
Employee e = (Employee)p;
e.setEmployeeNumber(5678);
Type Checking and Dynamic Binding (Cont’d)