October 2025
Intermediate to advanced
100 pages
2h 27m
English
| Puzzle 8 | What’s in the Box? |
| | interface Fruit |
| | |
| | class Strawberry() : Fruit |
| | class Mangosteen() : Fruit |
| | class Watermelon() : Fruit |
| | |
| | fun main() { |
| | val strawberries = arrayOf(Strawberry(), Strawberry(), Strawberry()) |
| | eatFruits(strawberries) |
| | } |
| | |
| | fun eatFruits(fruits: Array<Fruit>) { |
| | for (fruit in fruits) println("Ate a lovely ${fruit::class.simpleName}") |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess the output (or error) before moving to the next page. |
The program fails to compile, and the compiler displays the following error:
| | Argument type mismatch: |
Read now
Unlock full access