Interfaces are contracts between groups of programmers who write code without any knowledge of what other programmers are writing. To keep them (Programmers) know what other programmers are doing, interfaces are the way in java.
Abstract classes are same as interfaces, with few differences. They can contain implemented method bodies, fields which are not static and final. They are useful when some methods are common for classes and some method implementations are different. So, we can implement common methods in abstract class and write method (which are not implemented) signatures in it. What ever the class is implementing abstract class will provide their own method implementations for methods which are not implemented in abstract class.
Look at this tutorial if you've more doubts on this topic.
No comments:
Post a Comment