This post originated from an RSS feed registered with Java Buzz
by Javin Paul.
Original Post: Difference between Abstraction and Polymorphism in Java OOPS
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Abstraction and Polymorphism are very closely related and understanding difference between them is not as easy as it looks. Their operating model is also similar and based upon relationship between parent and child class. In fact, Polymoprhism needs great support of Abstraction to power itself, without Abstraction you cannot leverage power of Polymorphism. Let's understand this by what Abstraction and Polymorphism provides to an object oriented program. Abstraction is a concept to simplify structure of your code. Abstraction allows you to view things in more general terms rather than looking them as they are at the moment, which gives your code flexibility to deal with the changes coming in future. For example, if you were to design a program to control vehicles e.g. starting, stopping, horn, accelerator, breaks etc, how do you do that? would you design your program just to work with car or bike or would you think about different kinds of vehicles? This is where Abstraction comes into picture, it allows you think in terms of Vehicle rather than thinking in terms of Car. It provide that generalization much needed for a software to be reusable and customizable.