Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an enum class named Direction.
Kotlin
enum class [1] { NORTH, SOUTH, EAST, WEST }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for the enum class name
Using plural form instead of singular
✗ Incorrect
The enum class name should be Direction with capital D as per Kotlin naming conventions.
2fill in blank
mediumComplete the code to access the enum constant EAST from Direction.
Kotlin
val dir = Direction.[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or mixed case for enum constants
✗ Incorrect
Enum constants in Kotlin are uppercase by convention, so EAST is correct.
3fill in blank
hardFix the error in the enum class declaration by completing the blank.
Kotlin
enum [1] Direction {
NORTH, SOUTH, EAST, WEST
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing enumclass as one word
Using incorrect keywords like Enum or enum_class
✗ Incorrect
The correct syntax to declare an enum class in Kotlin is enum class.
4fill in blank
hardFill both blanks to declare an enum class Color with constants RED and BLUE.
Kotlin
enum [1] [2] { RED, BLUE }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for the class name
Using
object instead of class✗ Incorrect
The correct syntax is enum class Color to declare the enum class.
5fill in blank
hardFill all three blanks to create an enum class Weekday with constants MONDAY and FRIDAY.
Kotlin
enum [1] [2] { [3], FRIDAY }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for class or constant names
Missing the
class keyword✗ Incorrect
The enum class declaration is enum class Weekday and constants are uppercase like MONDAY.