Bird
0
0

Why does Kotlin use Any as the universal base type instead of Java's Object?

hard📝 Conceptual Q10 of 15
Kotlin - Data Types
Why does Kotlin use Any as the universal base type instead of Java's Object?
ABecause Kotlin does not have a universal base type.
BBecause Kotlin does not support inheritance.
CBecause Kotlin's <code>Any</code> does not allow null by default, improving null safety.
DBecause <code>Any</code> is only for primitive types.
Step-by-Step Solution
Solution:
  1. Step 1: Compare Kotlin Any and Java Object

    Java's Object allows null by default, Kotlin's Any is non-nullable by default.
  2. Step 2: Understand Kotlin's null safety design

    Kotlin separates nullable types with Any? to improve safety and reduce null pointer errors.
  3. Final Answer:

    Kotlin's Any disallows null by default, enhancing null safety. -> Option C
  4. Quick Check:

    Any improves null safety vs Object [OK]
Quick Trick: Any is non-nullable base type, unlike Java's Object [OK]
Common Mistakes:
MISTAKES
  • Thinking Kotlin lacks inheritance
  • Assuming Any is only for primitives
  • Believing Kotlin has no universal base type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes