• Post Reply Bookmark Topic Watch Topic
  • New Topic

Use of interface  RSS feed

 
vinayak jog
Ranch Hand
Posts: 83
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the use of interface while we can achive the same thing using abstract class. If it is useful in which senario interface come handy ? please help i think this is dumb question but i need help on this
 
Harnoor Singh
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can't extend multiple abstract classes but we can implement multiple interfaces. So it depends on the situation/problem whether we should use abstract class or interface. Also with interface we have the option of optional operation.
 
joy b chakravarty
Ranch Hand
Posts: 62
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A OO practice is that when extending make sure that the subclass and super class satisfies the IS-A relationship.
 
vinayak jog
Ranch Hand
Posts: 83
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
an example code will better explain please post if you have any short example
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface is a good tool for managing dependencies between classes. it avoids a class depends on other class specific implementation which makes maintenance nightmare.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!