Kotlin MCQs with answers Page - 4

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. How do you define an interface in Kotlin?

  • (A) interface MyInterface {}
  • (B) def MyInterface {}
  • (C) abstract class MyInterface {}
  • (D) protocol MyInterface {}

A

Admin • 828.03K Points
Coach

Q. What does the keyword 'open' signify in Kotlin?

  • (A) Variable is open to null
  • (B) Method or class can be overridden
  • (C) Indicates a getter method
  • (D) Creates a public method

A

Admin • 828.03K Points
Coach

Q. Which function is used to print a message to the console in Kotlin?

  • (A) echo()
  • (B) console.log()
  • (C) print() or println()
  • (D) printf()

A

Admin • 828.03K Points
Coach

Q. What will happen if you try to assign null to a non-nullable type in Kotlin?

  • (A) It compiles and runs
  • (B) It throws a warning
  • (C) It results in a compile-time error
  • (D) It skips the assignment

A

Admin • 828.03K Points
Coach

Q. How do you call a superclass constructor in Kotlin?

  • (A) super()
  • (B) parent()
  • (C) base()
  • (D) super.constructor()

A

Admin • 828.03K Points
Coach

Q. Which of the following represents a Kotlin lambda expression?

  • (A) lambda(x) => x*x
  • (B) fun x -> x*x
  • (C) { x -> x * x }
  • (D) x -> x*x

A

Admin • 828.03K Points
Coach

Q. Which of the following is used to perform multi-branch conditional expressions in Kotlin?

  • (A) if-else
  • (B) when
  • (C) switch
  • (D) select

A

Admin • 828.03K Points
Coach

Q. What does the keyword 'in' do in a for-loop in Kotlin?

  • (A) Checks the data type
  • (B) Declares a new variable
  • (C) Indicates the range to loop through
  • (D) Includes a file

A

Admin • 828.03K Points
Coach

Q. Which function in Kotlin can be used to filter a list?

  • (A) select()
  • (B) filter()
  • (C) map()
  • (D) choose()

A

Admin • 828.03K Points
Coach

Q. Which Kotlin collection allows duplicates?

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