Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a Kotlin function inside a module.
Android Kotlin
fun greet() : String {
return [1]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string
Using println instead of returning a string
✗ Incorrect
The function must return a String literal, so the text must be in quotes.
2fill in blank
mediumComplete the code to import a function from another module.
Android Kotlin
import com.example.moduleA.[1] fun main() { println(greet()) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the module name instead of the function
Using wrong function names
✗ Incorrect
You import the function name exactly to use it in your code.
3fill in blank
hardFix the error in the module dependency declaration in build.gradle.kts.
Android Kotlin
dependencies {
implementation(project([1]))
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra quotes inside the string
Omitting the colon prefix
Using just the module name without quotes
✗ Incorrect
The project path must be a string with colon prefix and no extra quotes inside.
4fill in blank
hardFill both blanks to create a Kotlin interface and implement it in a class.
Android Kotlin
interface [1] { fun sayHello(): String } class Greeter : [2] { override fun sayHello() = "Hi from Greeter" }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name as interface
Mismatching names between interface and implementation
✗ Incorrect
The interface is named Greeting and the class implements it by name.
5fill in blank
hardFill all three blanks to define a module-level constant and use it in a function.
Android Kotlin
const val [1] = [2] fun printVersion() { println("App version: $[3]") }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for the string value
Using different names for constant and usage
✗ Incorrect
Define APP_VERSION as a constant string and use it inside the function.