Given:

interface Animal {
    void eat();
}
 
// Insert code here

public class HouseCat implements Feline {
    public void eat() { }
}
Which of the following lines will allow the code to compile successfully?
Explanation
Declaring the void eat() method in one or both of the interfaces doesn't affect anything. You can define method in an interface with a default keyword The HouseCat class that implements the Feline interface, is correctly implementing the declared method.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes