Kotlin MCQs with answers Page - 9

Here, you will find a collection of MCQ questions on Kotlin. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 828.03K Points
Coach

Q. Which Kotlin keyword is used to define a custom getter or setter?

  • (A) getset
  • (B) field
  • (C) accessor
  • (D) property

A

Admin • 828.03K Points
Coach

Q. Which of the following can be used to create a thread in Kotlin?

  • (A) Thread()
  • (B) startThread()
  • (C) createThread()
  • (D) threadOf()

A

Admin • 828.03K Points
Coach

Q. Which Kotlin function combines map and flatten operations?

  • (A) combine()
  • (B) flatMap()
  • (C) mapFlat()
  • (D) collapse()

A

Admin • 828.03K Points
Coach

Q. What will be the output of `val list = listOf(1, 2, 3); println(list.first())`?

  • (A) 3
  • (B) 2
  • (C) 1
  • (D) Error

A

Admin • 828.03K Points
Coach

Q. Which function is used to generate a range of numbers in Kotlin?

  • (A) range()
  • (B) 1 to 10
  • (C) generate()
  • (D) loop()

A

Admin • 828.03K Points
Coach

Q. What is the Kotlin equivalent of Java's static methods?

  • (A) final
  • (B) object
  • (C) companion object
  • (D) static class

A

Admin • 828.03K Points
Coach

Q. What is the output of `val a = null ?: "default"`?

  • (A) null
  • (B) a
  • (C) default
  • (D) Error

A

Admin • 828.03K Points
Coach

Q. Which Kotlin function allows you to transform and return a new list?

  • (A) map()
  • (B) filter()
  • (C) forEach()
  • (D) take()

A

Admin • 828.03K Points
Coach

Q. What is the output of `println("Hello" is String)`?

  • (A) true
  • (B) false
  • (C) Error
  • (D) String

A

Admin • 828.03K Points
Coach

Q. What is returned by the 'filter' function in Kotlin?

  • (A) A new collection
  • (B) A string
  • (C) A boolean
  • (D) The original list