Posts

Showing posts with the label Interfaces

Interfaces – the next level of abstraction

Image
  Interfaces resemble  abstract classes  in that they include abstract methods that the programmer must define in the classes that inherit from the interface. In this way, interfaces contribute to code organization because they commit the child classes to the methods that they should implement. The use of interfaces become very helpful when we work in a team of programmers and want to ensure that all the programmers write the methods that they should work on, or even in the case of a single programmer that wants to commit himself to write certain methods in the child classes. An interface commits its child classes to abstract methods that they should implement. How to declare and implement an interface? We declare an interface with the interface keyword and, the class that inherits from an interface with the implements keyword. Let’s see the general case:   1 2 3 4 5 6 7 interface interfaceName { // Abstract methods } class Child implements interfaceName { // D...