Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

which senario we use abstract and interface in java  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

please exaplin the real time senario where we can use abstract and interface in java ...???

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

raja pulleboina wrote:
please exaplin the real time senario where we can use abstract and interface in java ...???



interface is basically a pure abstract class. interface only specifies the methods that should be present in any class which is implementing that interface.
abstract classes on other hand can have non-abstract methods i.e. methods which are already implemented. these methods can then be directly used in class extending the abstract class.

now the real life difference that comes is basically how you want to implement a certain design problem. interfaces generally define the behavior that a class needs to follow. abstract classes on other hand shows what type of class it is. this is also the difference in extending a class and implementing an interface.
 
Marshal
Posts: 60125
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you seen our FAQ?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!