Suppose, I have 2 configurations.
First one:
interface I {
...
}
class A implements I {
...
}
class B implements I {
...
}
class Component {
I i;
Component (I i) {
this.i = i;
}
}
Second one:
class C {
...
}
class A extends C {
...
}
class B extends C {
...
}
class Component {
C c;
Component (C c) {
this.c = c;
}
}
What in the difference between those two configurations which are using two different loose coupling mechanisms (based on interface and based on class)?
Why should I need to use interface over class?