Bird
0
0

What will be the output of this Kotlin code?

medium📝 Predict Output Q13 of 15
Kotlin - Data Types
What will be the output of this Kotlin code?
val a: Int = 100000
val b: Long = 10000000000L
val c: Float = 3.14f
val d: Double = 3.1415926535
println("$a $b $c $d")
A100000 10000000000 3.1400001 3.1415926535
B100000 10000000000 3.14 3.1415926535
C100000 10000000000 3.14f 3.1415926535
D100000 10000000000 3.14 3.1415927
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable types and precision

    a is Int (100000), b is Long (10000000000L), c is Float (3.14f), d is Double (3.1415926535).
  2. Step 2: Check printed values and precision

    Float prints as 3.1400001 due to precision limits, Double prints full precision (3.1415926535). So output matches 100000 10000000000 3.1400001 3.1415926535.
  3. Final Answer:

    100000 10000000000 3.1400001 3.1415926535 -> Option A
  4. Quick Check:

    Float prints with slight precision difference [OK]
Quick Trick: Float prints decimals with limited precision [OK]
Common Mistakes:
MISTAKES
  • Thinking Float prints exactly 3.14
  • Confusing Float and Double precision
  • Misreading Long large number formatting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes