• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Abstract vs. Interface

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Fellow ranchers,
I have a few questions in regards to Abstract vs. Interface.
What exactly are the difference between the two. Except the fact that Interfaces can be used a Object types I really don't see the difference. So here 's my questions.
1.) Abstract - Class which implement Abstracts must provide impletmentation of all prototype methods in Abstract. Or the implementing classes become abstract themselves.
Ans. I think this is true
2.) The same as above applies for interfaces?
Ans. I think this is true also.

3.) Can an Interface have an static member?
Thanks in advance for all the help,
Malik
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Travis,
1. Yes, if a class extends an Abstract class it must be provide implementation for all the methods. If it does not it must declared as an Abstract class itself.
2. Yes. Any class implementing an Interface must override all the interface methods.
3. Yes. Interface variables are automatically public and static.
The main difference is that Interfaces guarantee a given behaviour BUT not how the behaviour occurs.
Abstract classes can contain a mix of fully implemented methods and empty methods ie there's usually only one or two the subclass needs to provide implentation on.
Hope that helps.
------------------
Jane
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic