Introduction to Kotlin

  1. What is a program?

  2. Which keyword do you use to define a function in Kotlin?

  3. Which of the following do you need to create a Kotlin program that prints a line of text?

    Choose as many answers as you see fit.

  4. What do you expect this Kotlin code to do?

    fun main(args: Array<String>) {
      println("Hello, world!")
      println("It's a sunny and warm day!")
    }
    
  5. How would you modify this main() function so that it prints a 6-layer cake for someone's 4th birthday?

    fun main() {
      val age = 24
      val layers = 5
      printCakeCandles(age)
      printCakeTop(age)
      printCakeBottom(age, layers)
    }
    
  6. Which of these options correctly calls the function, below, and passes it valid input arguments?

    fun createMessage(name: String, location: String, age: Int) {
      println("My name is ${name}. I am from ${location}, and I am ${age} years old.")
    }