Kotlin MCQs with answers Page - 15

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

Q. Which function is used to create an empty list in Kotlin?

  • (A) empty()
  • (B) emptyList()
  • (C) listOf()
  • (D) nullList()

A

Admin • 833K Points
Coach

Q. Which Kotlin collection is unordered and does not allow duplicates?

  • (A) List
  • (B) Map
  • (C) Set
  • (D) ArrayList

A

Admin • 833K Points
Coach

Q. Which of the following is used to define an extension function?

  • (A) extend fun
  • (B) fun String.name()
  • (C) String.fun name()
  • (D) def extension name()

A

Admin • 833K Points
Coach

Q. Which function adds an element to a MutableList in Kotlin?

  • (A) append()
  • (B) push()
  • (C) add()
  • (D) insert()

A

Admin • 833K Points
Coach

Q. Which keyword is used to indicate a sealed class?

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

A

Admin • 833K Points
Coach

Q. What will be the result of `listOf(1,2,3).reversed()`?

  • (A) [3,2,1]
  • (B) Error
  • (C) [1,2,3]
  • (D) [1,3,2]

A

Admin • 833K Points
Coach

Q. Which function checks if all elements in a list satisfy a condition?

  • (A) checkAll()
  • (B) every()
  • (C) all()
  • (D) match()

A

Admin • 833K Points
Coach

Q. Which Kotlin operator checks if two references point to the same object?

  • (A) ===
  • (B) ==
  • (C) equals
  • (D) ::

A

Admin • 833K Points
Coach

Q. What is the output of `println("Kotlin".substring(0,3))`?

  • (A) KOT
  • (B) Kot
  • (C) Kotl
  • (D) Error

A

Admin • 833K Points
Coach

Q. How do you define an infix function in Kotlin?

  • (A) fun infix name()
  • (B) infix fun name()
  • (C) def infix name()
  • (D) infix() fun name()

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