One example of polymorphism would be to have an “Animal” class. This class could contain such aspects as whether the animal is carnivorous, herbivorous, or omnivorous, as well as how many legs it has. Then we could create a class called “Bear” which extends from the Animal class and it would set itself as omnivorous with 4 legs.
After the learning this week, can you identify the difference between Abstract classes and Interfaces? Be specific.
Interfaces are a sort of empty shell filled with names for methods which will not be filled until later when the interface is used.
Abstract classes are actual classes and can have both method signatures and definitions inside, unlike interfaces which just lay out the signatures for methods.
Update your learning journal from what you experienced this week with class.
This week we spent some time discussing interfaces, inner classes, polymorphism, abstract classes, and UML design. It was quite interesting to learn about the flexibility afforded using techniques such as polymorphism where you could establish general guidelines for parent classes which could later be built upon as more and more specialized descendent classes were created. I also enjoyed learning about UML’s as they seem a clean-cut way too quickly grasp how a group of classes are interacting.
No comments:
Post a Comment