aspose file tools*
The moose likes Beginning Java and the fly likes Abstract Class..??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract Class..???" Watch "Abstract Class..???" New topic
Author

Abstract Class..???

Nitish Agrawal
Greenhorn

Joined: Feb 11, 2008
Posts: 21
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 13, 2005
Posts: 36575
    
  16
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

Joined: Jun 06, 2007
Posts: 2713
    
    5

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


SCJP, SCWCD.
|Asking Good Questions|
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks Campbell and Amit
Rakesh Chaudhary
Ranch Hand

Joined: Feb 19, 2008
Posts: 120
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....


Acquire the unexpected.......
Preparing for SCJP 6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36575
    
  16
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

Joined: Aug 08, 2007
Posts: 202
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 ]

Brazil - Sun Certified Java Programmer - SCJP 5
http://www.camilolopes.com/ About Java - Update every Week.
Guide SCJP - tips that you need know http://blog.camilolopes.com.br/livrosrevistaspalestras/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract Class..???
 
Similar Threads
Abstract Class & Interface
Interface vs abstract class
abstract class
Nested classes - Series of doubts
Regarding abstract class