This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Abstract class and interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Abstract class and interface

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
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 ?


Yogesh Gnanapraksam
Ranch Hand

Joined: Dec 17, 2009
Posts: 133
"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.

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

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 http://www.coderanch.com/t/488459/Java-General/java/Interface-vs-Abstract-class


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Abstract class and interface
 
Similar Threads
Abstract Class Vs Class
tell me about abstract
Abstract, Interfaces!
When do we use abstract class and interface.
help with this q