Given:
3. interface Pet {
4. void eat();
5. }
6. class Dog implements Pet { public void eat() { } }
7. class Beagle extends Dog { public void eat() { } }
Which demonstrates the “program to an interface” principle?
A.
class PetFood extends Pet {
public void go(PetFood d) {
B.
eat();
}
C.
class PetFood {
public void go(Dog d) {
D.
eat();
}
E.
class PetFood {
public void go(Beagle b) {
F.
eat();
}
G.
interface PetFood implements Pet {
public void go(Pet d) {
H.
eat();
}
I.
class PetFood {
public void go(Pet p) {
J.
eat();
}