- What is the @JvmName annotation used for?
- It can be used to change the name of the Java class generated by the Kotlin compiler to contain top-level functions and properties.
- What is the @JvmStatic annotation used for?
- It indicates that the compiler should generate JVM static elements such as methods, getters, and setters for the annotated element.
- What does the @JvmOverloads annotation do when applied to a Kotlin function?
- It denotes that the compiler should generate overloaded methods for a function that provide the Kotlin-defined default parameter values, making them available from Java through the overloaded methods.
- What are use-site targets used for?
- They are used to specify which compiler-generated element an annotation should be applied to. For example, an annotation applied to a var property could use a use-site target to define whether the annotation should be applied to the generated field, getter, or setter for the annotated property.
- Is it true or false that companion objects can be given more meaningful names?
- True. A name can be given to a companion object by adding the name after the object keyword in the companion object declaration.
- What are two uses for companion objects?
- Factory methods
- Scoping of properties and methods to avoid polluting the namespace