Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Abstract Class & Interface  RSS feed

 
edirg559
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranchers:

I am really confused now between the Abstract Classes and Interfaces. I know that:

- Abstract classes have virtually no use, no value, no purpose of life UNLESS they are extended.
- Interfaces are used to prevent the infamous DDD (Deathly Diamond of Death).

I know somehow what the differences between two of them are, but I just can not describe it for certain (I am just too overloaded with OO polymorphysym information). Can you help me with the diffrences between two of them, and please feel free to whip me up with the correct information if I happened to understand two of them wrongly.

Thanks,
Erik
 
vignesh hariharan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interfaces can be considered as a blue print or a design of your class.. if you think that these are the methods going to be wrapped and going to be used in your implemented class then you can go for interfaces. and interfaces are best compared to abstract class in general.

abstract classes, if you know certain concrete defnition of your methods, then you have the facility to define it. and as well unknown can be left as such. but the thing is, only one abstract can be extended by a class. since multiple inheritance is not there in java.

where as interfaces allows you to implement as many interfaces as you wish.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!