previous |
start |
next
Polymorphism
- Interface variable holds reference to object of a class that
realizes the interface
Measurable x;
x = new BankAccount(10000);
x = new Coin(0.1, "dime");
- You can never construct an interface!
x = new Measurable(); // ERROR
- You can call any of the interface methods:
double m = x.getMeasure();
- Which method is called?
previous |
start |
next