Kotlin Basics Quiz Form
Test your knowledge of Kotlin fundamentals with this short quiz. All questions are required.
Which of the following is the correct way to declare a variable in Kotlin?
*
var x: Int = 5
int x = 5;
let x = 5
x := 5
What is the default visibility modifier for classes and functions in Kotlin?
*
public
private
protected
internal
Which keyword is used for defining an immutable variable in Kotlin?
*
val
var
let
const
How do you define a function in Kotlin?
*
fun myFunction() { }
function myFunction() { }
def myFunction() { }
fn myFunction() { }
What is the output type of the following function? fun add(a: Int, b: Int): Int { return a + b }
*
Int
String
Double
Unit
Select the correct way to create a nullable variable of type String.
*
var name: String? = null
var name: String = null
var name: ?String = null
var name = String?()
How confident are you in your Kotlin basics knowledge?
*
Not confident
1
2
3
4
Very confident
5
1 is Not confident, 5 is Very confident
Which of these is NOT a valid Kotlin data type?
*
Int
ArrayList
Boolean
Character
What is the result of 5 / 2 in Kotlin?
*
2
2.5
Error
None of the above
Which function is used to print output to the console in Kotlin?
*
println()
printLine()
console.log()
echo()
Submit Quiz
Should be Empty: