O'Reilly Forums: When To Use An Interface And An Abstract Class - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

When To Use An Interface And An Abstract Class

#1 User is offline   arun Dangerous 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 20-April 10

Posted 20 April 2010 - 11:14 PM

can u explain me clearly when to use an interface and an abstract class.........
is it a design decision or they can be used interchangeably in java.......
0

#2 User is offline   mrjayarajj 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 29-April 10

Posted 30 April 2010 - 12:38 AM

QUOTE (arun Dangerous @ Apr 20 2010, 11:14 PM) <{POST_SNAPBACK}>
can u explain me clearly when to use an interface and an abstract class.........
is it a design decision or they can be used interchangeably in java.......


its all depend upon your requirement

Interface http://code.google.com/p/mrjayarajj/source...ationAware.java

eg) In the above sample i used interface since i don't care about what is the actual class that implement, in this case i don't need a abstract class

Abstract class

eg) if you think object behave in maximum similar way and differ a little then go for abstract class
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users