0
0

[–] osX 0 points 0 points (+0|-0) ago 

Okay so using interfaces is useful for drawing a sort of outline of what you need to do. They're similar to abstract classes however you can implement multiple interfaces while you can only extend one abstract class.

Imagine you are Elon Musk and you want to make some cars. You have an interface that's a car, and let's say you have another interface that's a Tesla Model S. Your interface for a car contains an outline for everything that your car does and your interface for the Model S contains an outline for everything your Model S needs to do. Now Tesla doesn't just make Model S cars but all of it's cars share a same method that turns on the car. Rather than writing an abstract method in the interface for a car and then implementing this abstraction in the class that implements the interface, essentially writing the same code for each car, you can just write a default method that all cars share. Now if they make a new car then they know that it already has this default car starting method that they don't need to rewrite it every time. They can also overwrite this method if a car doesn't start in the same way however the default method exists already in the interface.

The point of default methods isn't to add on functionality later it's to set the default functionality of a method that you can change later on. Tesla wouldn't add any extra method signatures to an already implemented interface just because they come out with a new car that had more features. They simply define everything that all cars have in one interface (some may have default methods some may not) and then have another interface for a more specific type of car. For your other question: yes.