2.
Polymorphism allows you to invoke the right type of method for the appropriate type of object - you don't have to do anything to get that functionality.
For instance, assume you wanna call setName() for some DiskItem, which is actually a Link. Then Link.setName() will be called, because the object actually belongs to the Link class.
You can also define virtual methods in the DiskItem class.
From what I've seen, a common approach is to define the get/setName methods in the DiskItem class as abstract methods - e.g., String getName (DiskItem x) = 0; (or return false, or some error code).
This will force people to define them in the subclasses, for the appropriate type of objects.
I really don't know if any of this was any help, if you can be more specific, it would help.
Bookmarks