Bird
0
0

What is the output of this Kotlin code?

medium📝 Predict Output Q13 of 15
Kotlin - Data Types
What is the output of this Kotlin code?
val x = 0xF_A
val y = 0b1010_1010
println(x + y)
A270
B250
C420
D280
Step-by-Step Solution
Solution:
  1. Step 1: Convert hexadecimal and binary literals to decimal

    0xF_A means hex FA: F=15, A=10, so 15*16 + 10 = 250. 0b1010_1010 is binary 10101010 which equals 128+32+8+2=170.
  2. Step 2: Add the decimal values

    250 + 170 = 420.
  3. Final Answer:

    420 -> Option C
  4. Quick Check:

    (0xFA + 0b10101010) = 420 [OK]
Quick Trick: Convert hex and binary to decimal before adding [OK]
Common Mistakes:
MISTAKES
  • Misreading hex digits
  • Incorrect binary to decimal conversion
  • Ignoring underscores in literals

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes