Recall & Review
beginner
How do you call a Kotlin function from Java?
You call a Kotlin function from Java like a regular Java method. Kotlin compiles to JVM bytecode, so Java can use Kotlin classes and functions directly.
Click to reveal answer
beginner
What is the default Kotlin class name seen from Java if no @JvmName is used?If you have top-level Kotlin functions in a file named Example.kt, Java sees them in a class named ExampleKt by default.Click to reveal answer
intermediate
What annotation helps rename Kotlin functions or classes for Java callers?
The @JvmName annotation lets you specify a different name for Kotlin functions or classes when called from Java.
Click to reveal answer
intermediate
How do Kotlin properties appear when accessed from Java?
Kotlin properties appear as getter and setter methods in Java. For example, a Kotlin property 'val name' becomes 'getName()' in Java.
Click to reveal answer
intermediate
What is the purpose of the @JvmStatic annotation in Kotlin for Java callers?
@JvmStatic makes a Kotlin function or property static in the generated Java bytecode, so Java can call it without an instance.
Click to reveal answer
If you have a Kotlin file named Utils.kt with a top-level function, how do you call it from Java?
✗ Incorrect
Top-level Kotlin functions are placed in a class named after the file with 'Kt' appended, so Java calls UtilsKt.functionName().
Which annotation changes the name of a Kotlin function for Java callers?
✗ Incorrect
@JvmName lets you rename Kotlin functions or classes for Java interoperability.
How does a Kotlin 'val' property appear in Java?
✗ Incorrect
A Kotlin 'val' property appears as a getter method in Java, e.g., getPropertyName().
What does the @JvmStatic annotation do in Kotlin?
✗ Incorrect
@JvmStatic makes the annotated function or property static in the generated Java bytecode.
Can Java call Kotlin extension functions directly?
✗ Incorrect
Kotlin extension functions become static methods in Java and can be called like static methods.
Explain how Kotlin top-level functions are accessed from Java and how you can customize their names.
Think about the file name and the default class name Java sees.
You got /3 concepts.
Describe how Kotlin properties are represented in Java and how @JvmStatic affects calling Kotlin functions from Java.
Consider how Java accesses fields and static methods.
You got /3 concepts.