doesn't this make polymorphism useless (6)

1 Name: x : 2010-06-29 05:48 ID:bj54dl61

Hey all.

Say I have parent class Bicycle (this is in Java if you care) and it has children classes RoadBike and MountainBike.

Say I did this...

//=====================================================
public class TestBikes {
public static void main(String[] args){

Bicycle bike01, bike02, bike03;
bike01 = new Bicycle(20, 10, 1);
bike02 = new MountainBike(20, 10, 5, "Dual");
bike03 = new RoadBike(40, 20, 8, 23);
bike01.printDescription();
bike02.printDescription();
bike03.printDescription();

}
}
//=====================================================

...How is that any different than just making bike01, bike02, and bike03 their own respective types (instead of all Bicycle) and calling each unique object's printDescription() method?

This thread has been closed. You cannot post in this thread any longer.