• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

About interface and abstract classes

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know the definiton and how to use both interface and abstract....
but what is the use of both interface and abstract classes..
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find both your statements contradictory.
Would you care to rephrase your question?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vijai ganesh wrote:I know the definiton and how to use both interface and abstract....
but what is the use of both interface and abstract classes..



When you create an interface, you're defining a contract for what a class can do, without saying how the class will do it. It is up the the developer implementing the interface, how the class runs internally.

When you define an abstract class, you still defining a contract, but you can implement the class partially. When you know that some methods will be the same for all subtypes, you can provide those in your abstract class.

And finally, classes can implement many interfaces, but only can extend one class.

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the question 4,5 & 6 . I hope this would help
Abstract class and interface
reply
    Bookmark Topic Watch Topic
  • New Topic