What is the output of the following Java program?
interface Food {
public void printFlavor();
}
class Pepper implements Food {
public void printFlavor() {
System.out.println("spicy"); }
}
public class Lunch {
public static void main(String[] args) {
Food pepper = new
Pepper();
pepper.printFlavor();
}
}
Select one:
a. spicy
b. no output
c. the program does not compile
d. bland
e. bland
spicy
a. Spicy
import java.util.*;
interface Food{
public void printFlavor();
}
class Pepper implements Food{
public void printFlavor(){
System.out.print("Spicy");
}
}
public class Lunch
{
public static void main(String[] args) {
Food pepper = new Pepper();
pepper.printFlavor();
}
}
Get Answers For Free
Most questions answered within 1 hours.