Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the use of abatraction?

 
pardha saradhi74
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am still confusing with abstraction?
What is the use of abstraction and where can we use it?
Please if any one having good references please
let me know
thanking you inadvance
Saradhi
 
Irene Loos
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pardha,
You can use abstraction to create abstract class that has no use by itsef exept as it could be sublassed later to create concrete class - child. Consider a car in general is abstract class that has some behavior (4 wheels, moves when you push accelerator, stops, etc.) This is an abstract car. Now if you think about Nissan Maxima this is more concrete car with attributes that might be only available for this car. But all of the attributes and methods of class Car are available for class Nissan Maxima.

For more info you can read http://java.sun.com/docs/books/tutorial/java/javaOO/abstract.html
Hope this will help.
Irene
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An abstract class is used when you want to provide some implementation but not all. Other classes can subclass the abstract class, get the implemetation it already has, and then add their own implementation for the missing pieces.
Let's take an example from the AWT. The Component class is the abstract parent of all AWT component objects. It provides basi component functionality such as setting background and foreground colors, setting the bounds, adding and removing common listeners etc. But you would never want to actually instantiate a Component. All the children of Component get all the Component functionality for free. They can then provide whatever additional functionality they need.
It might be interesting to note that although Component is abstract it has no abstract methods!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic