Online Exam Quiz

questionQuestion  1 to 30

Which function is used to start a new activity in Android using Kotlin?

  • startActivity(Intent(this, NewActivity::class.java))
  • startActivity(NewActivity::class.java)
  • startNewActivity(Intent(this, NewActivity::class.java))
  • startNewActivity(NewActivity::class.java)
Mark for review

How do you handle an item click event in a RecyclerView adapter in Kotlin?

  • setOnClickListener { }
  • itemClickListener { }
  • onClick { }
  • setItemClickListener { }
Mark for review

Mark for review

How do you define a data class in Kotlin?

  • class Data(val a: Int)
  • data class Data(val a: Int)
  • class Data(a: Int)
  • data Data(val a: Int)
Mark for review

How do you define a companion object in Kotlin?

  • companion object
  • companion class
  • companion val
  • companion const
Mark for review

What is the default visibility modifier in Kotlin?

  • public
  • private
  • protected
  • internal
Mark for review

How do you define a lambda function in Kotlin?

  • { x: Int -> x * 2 }
  • lambda x: Int -> x * 2
  • x: Int => x * 2
  • func x: Int -> x * 2
Mark for review

What is the Kotlin equivalent of the Java 'switch' statement?

  • case
  • select
  • when
  • switch
Mark for review

What is the correct way to declare an extension function in Kotlin?

  • fun String.length: Int
  • fun String.length()
  • fun String.len(): Int
  • fun String.len()
Mark for review

Mark for review

Which of the following is a correct way to define a data class in Kotlin?

  • class Data(val a: Int)
  • data class Data(val a: Int)
  • class Data(a: Int)
  • data Data(val a: Int)
Mark for review

How do you make a network request in Kotlin using coroutines?

  • withContext(Dispatchers.IO) { }
  • GlobalScope.launch { }
  • coroutineScope { }
  • async { }
Mark for review

Which annotation is used to bind a view in a Kotlin Android activity?

  • @BindView
  • @ViewBind
  • @Bind
  • @FindView
Mark for review

What is the correct way to declare a nullable variable in Kotlin?

  • var name: String?
  • var name = null
  • var name: String = null
  • var name = ""
Mark for review

How do you check if a string is not empty in Kotlin?

  • if (string != "")
  • if (string.isNotEmpty())
  • if (string.isNotBlank())
  • if (string != null)
Mark for review

Which of the following is the correct way to define a sealed class in Kotlin?

  • sealed class MyClass
  • sealed abstract class MyClass
  • sealed MyClass
  • abstract sealed class MyClass
Mark for review

What is the correct way to create a sealed class in Kotlin?

  • sealed class MyClass
  • sealed abstract class MyClass
  • sealed MyClass
  • abstract sealed class MyClass
Mark for review

How do you start a new activity in Android using Kotlin?

  • startActivity(Intent(this, NewActivity::class.java))
  • startActivity(NewActivity::class.java)
  • startNewActivity(Intent(this, NewActivity::class.java))
  • startNewActivity(NewActivity::class.java)
Mark for review

How do you define a lambda function in Kotlin?

  • { x: Int -> x * 2 }
  • lambda x: Int -> x * 2
  • x: Int => x * 2
  • func x: Int -> x * 2
Mark for review

Which type in Kotlin represents a collection of key-value pairs?

  • List
  • Set
  • Map
  • Pair
Mark for review

How do you define an inline function in Kotlin?

  • inline fun func() { }
  • inline function func() { }
  • func inline() { }
  • function inline() { }
Mark for review

How do you define a data class in Kotlin?

  • class Data(val a: Int)
  • data class Data(val a: Int)
  • class Data(a: Int)
  • data Data(val a: Int)
Mark for review

Which of the following is the correct way to define a companion object in Kotlin?

  • companion object
  • companion class
  • companion val
  • companion const
Mark for review

How do you declare a constant in Kotlin?

  • const val CONSTANT_NAME
  • val CONSTANT_NAME
  • const CONSTANT_NAME
  • let CONSTANT_NAME
Mark for review

How do you create a singleton in Kotlin?

  • class Singleton { }
  • object Singleton { }
  • static class Singleton { }
  • object Singleton: Singleton { }
Mark for review

How do you initialize a lateinit variable in Kotlin?

  • lateinit var name: String
  • lateinit val name: String
  • var name: String = null
  • val name: String = null
Mark for review

How do you define a companion object in Kotlin?

  • companion object
  • companion class
  • companion val
  • companion const
Mark for review

What is the correct way to declare a list of integers in Kotlin?

  • listOf(1, 2, 3)
  • arrayListOf(1, 2, 3)
  • List<Int>(1, 2, 3)
  • ArrayList<Int>(1, 2, 3)
Mark for review

How do you create a sealed class in Kotlin?

  • sealed class MyClass
  • sealed abstract class MyClass
  • sealed MyClass
  • abstract sealed class MyClass
Mark for review

Mark for review

blinkerOnline

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • Answered
  • Not Answered
  • Marked for Review