0
0
Android Kotlinmobile~10 mins

Modularization in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A"Hello from module!"
Bprintln("Hello from module!")
CHello from module!
Dreturn "Hello from module!"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string
Using println instead of returning a string
2fill in blank
medium

Complete 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'
AMainActivity
Bgreet
CModuleA
Dgreeting
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the module name instead of the function
Using wrong function names
3fill in blank
hard

Fix 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'
A":moduleB"
B"moduleB"
CmoduleB
D"\":moduleB\""
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra quotes inside the string
Omitting the colon prefix
Using just the module name without quotes
4fill in blank
hard

Fill 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'
AGreeting
BGreeter
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name as interface
Mismatching names between interface and implementation
5fill in blank
hard

Fill 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'
AAPP_VERSION
B"1.0.0"
DVERSION
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for the string value
Using different names for constant and usage