80.0k views
2 votes
Consider the following class declarations.

public class Dog {

public Dog() {
System.out.println("woof");
}

public void speak() {
System.out.println("Bark");
}
}

public class Pomeranian extends Dog {

public Pomeranian() {
super();
}

public void speak() {
System.out.println("Yip");
}

public void speak(String emotion) {
System.out.println(emotion);
}
}
Pomeranian shows an example of_____________.

a. Overriding and overloading'
b. Neither overriding or overloading
c. Overriding only
d. Overloading only

User Ronelle
by
5.3k points

1 Answer

3 votes
Override only
Reason because the same method speak is in the parent and child class
User Pmor
by
4.6k points