2026\2027
Which of the following is allowed in a Java interface?
- correct answer Heading for public methods.
Given an interface called Pourable, how should an interface called Drinkable de declared so it inherits all
of the methods header from Pourable and adds some additional methods headers?
- correct answer public class Drinkable extends Pourable
Where should the keyword abstract be used in a class definition for an abstract class?
- correct answer Both of the above.
Given the following class definitions:
public class Carnivore{
public Carnivore() {}
public void speak() {System.out.println("Grrr"); }
}
public class Cat extends Carnivore {
public Cat() {}
public void speak() {System.out.println("Meow"); }
}
What output will the following statements generate?