I'm a CS undergrad so my answers aren't exactly correct, just my understanding ![Smile :) :)](/styles/default/xenforo/vbSmilies/Normal/smile.gif)
That's pretty much it. To me the important thing to keep in mind is that an encapsulated class only shows what it does, not how it does it.
My understanding of this is admittedly vague. My Java lecturer would talk about it early on but I didn't really appreciate the concepts when I was so new to it all. Polymorphism basically means the ability to appear in many forms/shapes. It's closely linked to inheritance. For example say you have a superclass called MediaItem. Two subclasses called DVD and CD extend this superclass. Now say you have a collection (say an ArrayList) of MediaItem objects. Within this collection you can store DVD and CD objects. Now say you want the title of all objects within this collection (through a simple get method that's in MediaItem). If you hadn't taken advantage of inheritance and polymorphism concepts, you'd need separate collections for DVD and CD items along with other sloppy code issues. Imagine you had 20+ subclasses of MediaItem; things get messy awfully quick.
If I'm wrong please correct me![Smile :) :)](/styles/default/xenforo/vbSmilies/Normal/smile.gif)
![Smile :) :)](/styles/default/xenforo/vbSmilies/Normal/smile.gif)
Encapsulation refers to Objects effectively, an object that defines a circle outputs a circle, though the way the circle is worked out is 'encapsulated' in such a way that it keeps the user oblivious. If the object outputs a circle, all the inner workings out are irrelevant
That's pretty much it. To me the important thing to keep in mind is that an encapsulated class only shows what it does, not how it does it.
Polymorphism covers quite a few things, if you were to feed an object certain arguments and depending on what arguments are fed into the object, different outputs are created - based on the information fed in, the output could be a square, circle, triangle.
My understanding of this is admittedly vague. My Java lecturer would talk about it early on but I didn't really appreciate the concepts when I was so new to it all. Polymorphism basically means the ability to appear in many forms/shapes. It's closely linked to inheritance. For example say you have a superclass called MediaItem. Two subclasses called DVD and CD extend this superclass. Now say you have a collection (say an ArrayList) of MediaItem objects. Within this collection you can store DVD and CD objects. Now say you want the title of all objects within this collection (through a simple get method that's in MediaItem). If you hadn't taken advantage of inheritance and polymorphism concepts, you'd need separate collections for DVD and CD items along with other sloppy code issues. Imagine you had 20+ subclasses of MediaItem; things get messy awfully quick.
If I'm wrong please correct me
![Smile :) :)](/styles/default/xenforo/vbSmilies/Normal/smile.gif)