Polymorphic Method Call Output
Consider the following class declarations.
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());
}
}
What is printed when the main method in the TestFruit class is executed?
A
Compilation Error
B
generic
C
citrus
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 |
Items per page:
10
1 – 3 of 3
APFIVE