It's not a secret anymore!
The moose likes Java in General and the fly likes what is the use of abatraction? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "what is the use of abatraction?" Watch "what is the use of abatraction?" New topic

what is the use of abatraction?

pardha saradhi74

Joined: Jul 07, 2001
Posts: 9
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
Irene Loos
Ranch Hand

Joined: Apr 15, 2002
Posts: 78
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
Hope this will help.

Irene Loos
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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!

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
I agree. Here's the link:
subject: what is the use of abatraction?
It's not a secret anymore!