Kotlin MCQs with answers Page - 16

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 • 802.91K Points
Coach

Q. Which function returns a portion of a list?

  • (A) part()
  • (B) slice()
  • (C) take()
  • (D) split()

A

Admin • 802.91K Points
Coach

Q. Which function gets the first element matching a condition?

  • (A) findFirst()
  • (B) matchFirst()
  • (C) firstOrNull()
  • (D) first()

A

Admin • 802.91K Points
Coach

Q. How do you repeat a string 3 times in Kotlin?

  • (A) "Kotlin" * 3
  • (B) repeat("Kotlin", 3)
  • (C) repeat(3) { "Kotlin" }
  • (D) "Kotlin".repeat(3)

A

Admin • 802.91K Points
Coach

Q. What is the use of the `takeIf()` function?

  • (A) Always returns true
  • (B) Returns the object if condition is true, else null
  • (C) Takes the first element of a list
  • (D) Returns false if condition is false

A

Admin • 802.91K Points
Coach

Q. Which function returns the number of items in a collection?

  • (A) length()
  • (B) count()
  • (C) total()
  • (D) size()

A

Admin • 802.91K Points
Coach

Q. Which of the following can be used to filter a list?

  • (A) where()
  • (B) select()
  • (C) filter()
  • (D) cut()

A

Admin • 802.91K Points
Coach

Q. Which scope function uses 'this' as the receiver and returns the result of lambda?

  • (A) let
  • (B) run
  • (C) also
  • (D) apply

A

Admin • 802.91K Points
Coach

Q. What will be the output of `println(listOf(1,2,3).contains(2))`?

  • (A) false
  • (B) true
  • (C) 2
  • (D) 1

A

Admin • 802.91K Points
Coach

Q. Which function checks if any elements match a condition?

  • (A) some()
  • (B) exists()
  • (C) any()
  • (D) matchAny()

A

Admin • 802.91K Points
Coach

Q. Which keyword prevents further subclassing in Kotlin?

  • (A) final
  • (B) sealed
  • (C) abstract
  • (D) closed

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ