Bird
0
0

Which statement about Kotlin's Unit type is true?

easy📝 Conceptual Q2 of 15
Kotlin - Data Types
Which statement about Kotlin's Unit type is true?
A<code>Unit</code> can hold any type of value.
B<code>Unit</code> is used to represent null values.
C<code>Unit</code> is a singleton object with only one value.
D<code>Unit</code> is the superclass of all types.
Step-by-Step Solution
Solution:
  1. Step 1: Recall the nature of Unit and evaluate other options

    Unit in Kotlin is a type with exactly one value, also called a singleton object. Unit does not hold any value like a container, is not related to null, and is not a superclass.
  2. Final Answer:

    Unit is a singleton object with only one value. -> Option C
  3. Quick Check:

    Unit = singleton object [OK]
Quick Trick: Unit has exactly one value, like a singleton [OK]
Common Mistakes:
MISTAKES
  • Thinking Unit can hold multiple values
  • Confusing Unit with null
  • Assuming Unit is a superclass

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes