This content has been marked as final. Show 3 replies
well atom, how many protons do you have... one... that's inheritance.
how many chemical reactions do you support? as many as required... that's the BunsenBurner, and the SoreBum interfaces.
An abstract class can (and frequently does) contain implementation.
An interface cannot contain implementation.
Java doesn't support multiple inheritance (like C++)... so you can extend exactly 0 or 1 classes (which isn't quit true, you inherit Object if you don't extend anything which does).
You can implement as many interfaces as is required.
If you want a discussion of why, there's eight miles of verbal diarrhea on the web about it... just google it.
Message was edited by: corlettk
Thanks a Lot!
i want to add a few more differences --
1.The variable defined inside an interface is public, static and final means it's basically a constant,But in case of abstract class you can hide the variable in the implementation class means you can change the value of the variable.
One very important thing about the these two feature is when to use what?
Ans:If a group of object is having some common property such that they are not going to be changed over a period then create an Abstract class out of that property.But if only some object is having a common property but not all then create an interface out of that property and implement all that property in Subclass.