0
0
Kotlinprogramming~10 mins

Calling Kotlin from Java - Interactive Code Practice

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

Complete the code to call a Kotlin function from Java.

Kotlin
KotlinClass.[1]();
Drag options to blanks, or click blank then click option'
Astart
Bmain
Crun
Dgreet
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong method name like 'main' or 'run'.
2fill in blank
medium

Complete the Java code to create an instance of a Kotlin class.

Kotlin
KotlinClass [1] = new KotlinClass();
Drag options to blanks, or click blank then click option'
Aobj
Binstance
CkotlinObj
DkotlinInstance
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid variable names or keywords.
3fill in blank
hard

Fix the error in calling a Kotlin function with parameters from Java.

Kotlin
int result = kotlinObj.[1](5, 3);
Drag options to blanks, or click blank then click option'
AaddNumbers
Badd
Csum
Dcalculate
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names like 'add' or 'sum'.
4fill in blank
hard

Fill both blanks to call a Kotlin property getter from Java.

Kotlin
String name = kotlinObj.[1]();
System.out.println(name [2] " is called from Java.");
Drag options to blanks, or click blank then click option'
AgetName
B+
C-
DsetName
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'setName' instead of 'getName'.
Using '-' instead of '+' for concatenation.
5fill in blank
hard

Fill all three blanks to call a Kotlin companion object function from Java.

Kotlin
int max = KotlinClass.[1].[2]([3]);
Drag options to blanks, or click blank then click option'
ACompanion
BmaxOf
C10, 20
Dcompanion
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'companion' instead of 'Companion'.
Passing arguments incorrectly.