Olete.in
Articles
Mock Tests
🧪 Kotlin (programming language) MCQ Quiz Hub
Kotlin MCQ Set 1
Choose a topic to test your knowledge and improve your Kotlin (programming language) skills
1. Kotlin is developed by?
Google
JetBrains
Microsoft
Adobe
2. Which of following is used to handle null exceptions in Kotlin?
Range
Sealed Class
Elvis Operator
Lambda function
3. Which file extension is used to save Kotlin files.
.java
.kot
.kt or .kts
andriod
4. All classes in Kotlin classes are by default?
public
final
sealed
abstract
5. What is correct way to create an arraylist in Kotlin?
val map = hashMapOf(1 to "one", 2 to "two", 3 to "three")
enum class Color {RED, GREEN, BLUE}
val list = arrayListOf(1, 2, 3)
val set = hashSetOf(1, 2, 3)
6. 6. What is an immutable variable?
A variable that cannot change, read-only
A variable used for string interpolation
A variable that can be changed
None of these
7. Which of follwing targets currently not supported by Kotlin?
LLVM
.NET CLR
Javascript
None of These
8. How to make a multi lined comment in Kotlin?
//
/* */
/ multi line comment /
None of These
9. 9. How do you get the length of a string in Kotlin?
str.length
length(str)
str.lengthOf
None of the mentioned
10. Which of the followings constructors are available in Kotlin?
Primary constructor
Secondary constructor
Both 1 & 2
None of These
11. Which of the following extension methods are used in Kotlin?
Read texts () & Headlines ()
Buffer reader ()
Read each line ()
All of the above
12. There are two types of constructors in Kotlin which are-
Primary & Secondary constructor
Default & No-arg constructor
Parameterized & constant Constructor
None of the above
13. Which of the following is not the basic data types in Kotlin?
Numbers
Strings
Arrays
Lists
14. Which of following option is used to handle null exceptions in Kotlin?
Range
Elvis Operator
Sealed Class
Lambda function
15. Kotlin was developed under the .......... license.
Apache 1.0
Apache 2.0
Apache 1.1
None of the above
16. You have created an array to hold three strings. When you run the code bellow, the compiler displays an error. Why does the code fail? val names = arrayOf(3) names[3]= "Delta"
Arrays use zero-based indexes. The value 3 is outside of the array's bounds
You accessed the element with an index but should have used.set(
You declared the array with val but should have used var
You cannot changes the value of an element of an array. You should have used a mutable list.
17. If a class has one or more secondary constructors, what must each of them do?
Each secondary constructor must call super().
Each secondary constructor must call base().
Each secondary constructor must directly or indirectly delegate to the primary.
Each secondary constructor must have the same name as the class.
18. When you can omit constructor keyword from the primary constructor?
It can be omitted only if an init block is defined
It can be omitted anytime; it is not mandatory.
It can be omitted if secondary constructors are defined.
It can be omitted when the primary constructor does not have any modifiers or annotations.
19. How many different kinds of constructors are available for kotlin classes?
Two.
None.
Four.
One.
Submit