Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract Class..???

 
Nitish Agrawal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why we use abstrat class & abstract method...???
What's the Purpose behind that.???
If we dont use Abstract then wat will happen
or if we use then what..???
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Abstract class is like an interface... what are the methods need to develop a common thing... you just put into the abstract class....

when ever you need the method you can use......
 
Campbell Ritchie
Sheriff
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by seetharaman venkatasamy:
Hi,

Abstract class is like an interface...
Hardly. You can have implemented methods in an abstract class, you can't in an interface.
You can inherit from one abstract class only, you can implement several interfaces (in most cases).

I think there is a spectrum from most abstract (interfaces) to most concrete (enums), like this:-

interface----abstract class----concrete class----enum member
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract classes are used either to put common functionality together or to represent real world abstract entities
E.g person is abstract where as student, employee may be concrete.

Take a look at this for more information.


Hope this helps
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell and Amit
 
Rakesh Chaudhary
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Campbell Ritchie,

I think remembering the spectrum you mentioned solved problems of many beginners who struggle in initial fundamentals of interfaces and abstract classes.

Can you provide some more spectrum about Collections ???

Thanks Campbell....
 
Campbell Ritchie
Sheriff
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't ask unrelated questions on a thread somebody else started. Read this FAQ.

Somebody posted a table of collections implementations on JavaRanch about a year ago, but I can't remember where. Try searching for it.
 
camilo lopes
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we want to implements differents. for example:

then, each class implemented of form differente the abstract method.

[ July 18, 2008: Message edited by: camilo lopes ]
[ July 18, 2008: Message edited by: camilo lopes ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic