Kotlin and Java compile to the same JVM bytecode—call Java from Kotlin and vice versa without bridges. Mind platform types, nullability annotations, and JVM name mangling for top-level functions.
Calling Java from Kotlin
Java types without nullability annotations become platform types—treat them as nullable or not explicitly. SAM conversions let Kotlin lambdas implement Java functional interfaces.
Exposing Kotlin to Java
@JvmStaticon companion methods@JvmOverloadsfor default parameters@file:JvmName("Util")for top-level APIs
Important interview questions and answers
- Q: Platform type?
A: Kotlin's relaxed type when Java lacks @Nullable/@NonNull—compile allows nullable or non-null calls at your risk. - Q: Can Java use Kotlin extension functions?
A: As static methods on a generated file class, e.g.StringsKt.capitalize(s).
Self-check
- What annotation exposes companion methods as Java statics?
- What is a platform type?
Pitfall: Java platform types (T!) need explicit null handling—annotate Java with @Nullable/@NonNull when possible.
Interview prep
- Call Java from Kotlin?
Direct JDK and library use—no wrapper required.
- Platform types?
Java nullability unknown—annotate Java or handle null explicitly.