Online Exam Quiz

questionQuestion  1 to 30

Which keyword is used to define a function in Kotlin?

  • def
  • fun
  • function
  • func
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

Mark for review

Mark for review

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

  • List
  • Set
  • Map
  • Pair
Mark for review

Which of the following is the correct way to declare a variable in Kotlin?

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

How do you create an instance of a class in Kotlin?

  • ClassName()
  • new ClassName()
  • ClassName
  • ClassName.new()
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

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

What is the correct way to get a reference to a TextView in Kotlin?

  • findViewById<TextView>(R.id.textView)
  • findViewById(R.id.textView)
  • findTextView(R.id.textView)
  • getView<TextView>(R.id.textView)
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 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 library is commonly used for dependency injection in Kotlin for Android development?

  • Dagger
  • Hilt
  • Koin
  • Dagger-Hilt
Mark for review

How do you define a Fragment in Kotlin?

  • class MyFragment : Fragment()
  • class MyFragment extends Fragment()
  • class MyFragment inherits Fragment()
  • class MyFragment implements Fragment()
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

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

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

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

  • case
  • select
  • when
  • switch
Mark for review

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 handle an HTTP response in Kotlin using the Retrofit library?

  • response.body()
  • response.data()
  • response.get()
  • response.json()
Mark for review

How do you convert a Kotlin list to a mutable list?

  • list.toMutableList()
  • list.toChangeableList()
  • list.asMutable()
  • list.mutableCopy()
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

How do you handle a background task in Kotlin using coroutines?

  • withContext(Dispatchers.IO) { }
  • GlobalScope.launch { }
  • coroutineScope { }
  • async { }
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

Which keyword is used to indicate that a Kotlin class can be inherited from?

  • open
  • public
  • extendable
  • inheritable
Mark for review

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

  • setOnClickListener { }
  • itemClickListener { }
  • onClick { }
  • setItemClickListener { }
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

How do you define a primary constructor in a Kotlin class?

  • constructor(name: String)
  • primary constructor(name: String)
  • init(name: String)
  • class ClassName(name: String)
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