Kotlin MCQs with answers Page - 2

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. What is the output of: println("Hello " + "Kotlin")?

  • (A) Hello + Kotlin
  • (B) HelloKotlin
  • (C) Hello Kotlin
  • (D) Kotlin Hello

A

Admin • 802.91K Points
Coach

Q. Which of the following is a correct way to create a list in Kotlin?

  • (A) val list = List(1, 2, 3)
  • (B) val list = [1, 2, 3]
  • (C) val list = listOf(1, 2, 3)
  • (D) val list = makeList(1, 2, 3)

A

Admin • 802.91K Points
Coach

Q. What is 'data class' used for in Kotlin?

  • (A) Database connection
  • (B) To create classes with default toString, equals, and hashCode
  • (C) To perform data transfer
  • (D) To store JSON data

A

Admin • 802.91K Points
Coach

Q. What does 'companion object' do in Kotlin?

  • (A) Creates an interface
  • (B) Provides access to static-like methods
  • (C) Creates a singleton
  • (D) Creates an enum

A

Admin • 802.91K Points
Coach

Q. How can you handle exceptions in Kotlin?

  • (A) if-else
  • (B) throw-try
  • (C) try-catch
  • (D) assert

A

Admin • 802.91K Points
Coach

Q. What is the purpose of the Elvis operator (?:) in Kotlin?

  • (A) Loops through a list
  • (B) Checks types
  • (C) Provides a default value when a variable is null
  • (D) Compares strings

A

Admin • 802.91K Points
Coach

Q. What is 'sealed class' in Kotlin used for?

  • (A) Creating open classes
  • (B) Restricting class hierarchy
  • (C) Defining multiple interfaces
  • (D) Defining database models

A

Admin • 802.91K Points
Coach

Q. Which function in Kotlin is used to iterate over a list?

  • (A) map()
  • (B) forEach()
  • (C) repeat()
  • (D) loop()

A

Admin • 802.91K Points
Coach

Q. Which Kotlin keyword is used to implement an interface?

  • (A) use
  • (B) with
  • (C) implement
  • (D) override

A

Admin • 802.91K Points
Coach

Q. Which tool compiles Kotlin code to JVM bytecode?

  • (A) JDK
  • (B) kotlinc
  • (C) javac
  • (D) kotlinvm

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