Online Exam Quiz

questionQuestion  1 to 30

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

Which library is commonly used for dependency injection in Kotlin for Android development?

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

Which of the following is a correct extension function syntax in Kotlin?

  • fun String.length: Int
  • fun String.length()
  • fun String.len(): Int
  • fun String.len()
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 keyword is used to indicate that a Kotlin class can be inherited from?

  • open
  • public
  • extendable
  • inheritable
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

How do you define a companion object in Kotlin?

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

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 create an instance of a class in Kotlin?

  • ClassName()
  • new ClassName()
  • ClassName
  • ClassName.new()
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 declare a constant in Kotlin?

  • const val CONSTANT_NAME
  • val CONSTANT_NAME
  • const CONSTANT_NAME
  • let CONSTANT_NAME
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 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

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 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

What is the correct way to handle null safety in Kotlin?

  • if (variable != null)
  • variable?.let { }
  • variable != null ? ...
  • try { variable } catch {}
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

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

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 item click event in a RecyclerView adapter in Kotlin?

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

Mark for review

How do you create a read-only variable in Kotlin?

  • val name: String
  • var name: String
  • const name: String
  • let name: String
Mark for review

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

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

What is the correct way to create an ArrayList in Kotlin?

  • ArrayList<String>()
  • arrayListOf<String>()
  • ArrayList<String>
  • listOf<String>()
Mark for review

Which library is commonly used for dependency injection in Kotlin for Android development?

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

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

  • List
  • Set
  • Map
  • Pair
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

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