Inheritance Constructor Call Order
Consider the following class definitions.
public class Seed {
Seed() { System.out.println("Planting a seed"); }
}
public class Fruit extends Seed {
Fruit() { System.out.println("Growing a fruit"); }
}
public class Lychee extends Fruit {
Lychee() { System.out.println("Lychee is sweet"); }
}
What is the output when the statement Lychee l = new Lychee(); is executed?
A
Planting a seed
Lychee is sweet
B
Planting a seed
Growing a fruit
Lychee is sweet
C
Lychee is sweet
D
Growing a fruit
Lychee is sweet
Planting a seed
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | zhanghan003 | 1 | 1 | 0m 00s | 100 |
| #2 | zgj07310417 | 1 | 1 | 0m 44s | 56 |
| #3 | parth.taur227 | 1 | 1 | 1m 27s | 13 |
| #4 | meromaroseif | 0 | 1 | 0m 45s | -55 |
Items per page:
10
1 – 4 of 4
