Complete the code to make the function callable as a static method from Java.
object Utils {
@[1]
fun greet() = "Hello from Kotlin"
}The @JvmStatic annotation makes the function callable as a static method from Java.
Complete the code to expose the property as a public field in Java.
class Config { @[1] val version = "1.0" }
The @JvmField annotation exposes the Kotlin property as a public field in Java, without getter/setter methods.
Fix the error by choosing the correct annotation to allow Java static access to the companion object's function.
class Helper { companion object { @[1] fun help() = "Helping" } }
Inside companion objects, @JvmStatic allows calling the function as a static method from Java.
Fill both blanks to expose a property as a public static field accessible from Java.
class Constants { companion object { @[1] @[2] val MAX_COUNT = 100 } }
Using both @JvmField and @JvmStatic on a companion object property exposes it as a static field in Java.
Fill all three blanks to create a Kotlin object with a static function and a public field accessible from Java.
object Logger {
@[1]
fun log(message: String) = println(message)
@[2]
val DEFAULT_TAG = "APP"
}@JvmStatic makes the function static for Java callers. @JvmField exposes the property as a public field.