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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstract class and interface

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Can someone please explain the following statements:

"In case where you want to use implementation inheritance then it is usually provided by an abstract base class" - what is implementation/class inheritance ?

"Abstract classes let you define some default behaviour and force subclasses to provide any specific behaviour" - what does behaviour mean here, any example ?


 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

"Abstract classes let you define some default behaviour and force subclasses to provide any specific behaviour"


Abstract class can have concrete methods which can provide a default behaviour.
A class marked as abstract can have methods which have the method body (i.e method defintion) .
So if any class extends this abstract class it may or may not override the default behaviour provided by the concrete method in an abstract class.
For eg:


But an interface is 100% abstract which implies that there are no concrete methods so the class implementing the interface must provide
the behaviour for all the methods spcified in the interface.

 
Bartender
Posts: 11497
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:
  • Report post to moderator
Please do not waste everybodys time by asking the same question all over again. Last time you asked it, you were provided a link with the explanation. In case you did not understand anything from that link you can continue in the previous post https://coderanch.com/t/488459/Java-General/java/Interface-vs-Abstract-class
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic