Polymorphic Method Call Output
When TestFruit.main() is executed, what is printed?
public class Fruit {
public String flavor() { return "generic"; }
}
public class Orange extends Fruit {
public String flavor() { return "citrus"; }
public String color() { return "orange"; }
}
public class TestFruit {
public static void main(String[] args) {
Fruit f = new Orange();
System.out.println(f.flavor());
}
}
A
generic
B
citrus
C
Compilation Error
D
orange
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | suhanakochhar006 | 1 | 1 | 0m 44s | 56 |
| #3 | psak12 | 1 | 1 | 1m 30s | 10 |
APFIVE