Recall & Review
beginner
What does it mean that a String is immutable in Kotlin?
It means once a String is created, its content cannot be changed. Any modification creates a new String.
Click to reveal answer
beginner
How do you create a String in Kotlin?
You create a String by enclosing text in double quotes, for example:
val greeting = "Hello".Click to reveal answer
beginner
Can you change a character inside a Kotlin String directly?
No, you cannot change characters inside a String directly because Strings are immutable. You must create a new String if you want changes.
Click to reveal answer
beginner
What happens when you use the plus operator (+) to add text to a String in Kotlin?
A new String is created that combines the original and the added text. The original String stays unchanged.
Click to reveal answer
intermediate
Why is String immutability useful in programming?
It helps avoid unexpected changes, makes programs safer, and allows sharing Strings without copying.
Click to reveal answer
In Kotlin, what happens if you try to change a character in a String directly?
✗ Incorrect
Strings in Kotlin are immutable, so you cannot change characters directly.
How do you create a new String by adding text to an existing String in Kotlin?
✗ Incorrect
The plus (+) operator creates a new String combining the original and added text.
Which of these is true about Kotlin Strings?
✗ Incorrect
Kotlin Strings are immutable, meaning their content cannot be changed after creation.
Why might immutability of Strings improve program safety?
✗ Incorrect
Immutability prevents unexpected changes, which helps avoid bugs.
What is the correct way to declare a String variable in Kotlin?
✗ Incorrect
In Kotlin, Strings are declared with val or var and double quotes for text.
Explain what immutability means for the String type in Kotlin and why it matters.
Think about what happens if you try to change a letter inside a String.
You got /3 concepts.
Describe how you would add text to an existing String in Kotlin and what happens behind the scenes.
Remember Strings are immutable, so adding text creates something new.
You got /3 concepts.