I know the concepts of Abstract Class and Interface Class. But I want real time example which explains both the concept in our design. Can anyone help with this?
2条回答 默认 最新
duanlei2458 2016-08-03 06:32关注Here I am mentioning some point what we can do with abstract class and interface
- In abstract class you can define abstract methods which should be public or protected. but in Interface you can define public abstract method only.
- In abstract class you can define data members and constants but in interface you can define constants only.
- In abstract class you can define body of method and you can inherit in sub class, but in interface you can not define body of method.
- you can implement multiple interface in a sub class, but you can not inherit multiple abstract classes in a sub class.
Example
In Major Frameworks, uses interfaces for different types of data source class. If we want to make data source class for new introduced database then we must have to implement their interface in our class so it make well maintained code and methods parameters.
解决 无用评论 打赏 举报