Recall & Review
beginner
What is a data type in Kotlin?
A data type defines the kind of value a variable can hold, like numbers, text, or true/false values.
Click to reveal answer
beginner
What does
val mean in Kotlin?val declares a read-only variable, which means its value cannot change after it is set.Click to reveal answer
beginner
Explain type inference in Kotlin.
Type inference means Kotlin can guess the data type of a variable from the value you assign, so you don't always need to write the type explicitly.
Click to reveal answer
beginner
What is the difference between
Int and Double in Kotlin?Int holds whole numbers without decimals, while Double holds numbers with decimals.Click to reveal answer
beginner
How do you explicitly declare a variable type in Kotlin?
You write the variable name, then a colon, then the type. For example:
val age: Int = 30.Click to reveal answer
Which keyword declares a variable whose value cannot change in Kotlin?
✗ Incorrect
val declares a read-only variable, while var allows changes.What type will Kotlin infer for
val name = "Anna"?✗ Incorrect
Kotlin infers
String because the value is text in quotes.Which data type should you use for a number with decimals?
✗ Incorrect
Double holds decimal numbers.How do you explicitly declare a variable of type Int?
✗ Incorrect
The correct syntax is
val number: Int = 5.What happens if you try to change a
val variable?✗ Incorrect
val variables cannot be reassigned; the compiler will show an error.Explain how Kotlin's type inference helps when declaring variables.
Think about how Kotlin figures out the type from the value you give.
You got /3 concepts.
Describe the difference between
val and var in Kotlin.Consider if the variable can be changed or not.
You got /3 concepts.