0
0
Kotlinprogramming~10 mins

Enum class declaration in Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Adirection
BDirection
CEnumDirection
DDirections
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for the enum class name
Using plural form instead of singular
2fill in blank
medium

Complete 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'
Aeast
BeAST
CEast
DEAST
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or mixed case for enum constants
3fill in blank
hard

Fix 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'
Aclass
Benumclass
CEnum
Denum_class
Attempts:
3 left
💡 Hint
Common Mistakes
Writing enumclass as one word
Using incorrect keywords like Enum or enum_class
4fill in blank
hard

Fill 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'
Aclass
Bobject
CColor
Dcolor
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for the class name
Using object instead of class
5fill in blank
hard

Fill 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'
Aclass
BWeekday
CMONDAY
Dweekday
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for class or constant names
Missing the class keyword