Kotlin MCQ Questions & Answers - Mobile Development
Kotlin MCQs : This section focuses on "Kotlin" in Mobile Development. These Multiple Choice Questions (MCQ) should be practiced to improve the Kotlin skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Kotlin was developed by?
A. IBM
B. NetBeans
C. JetBrains
D. Oracle
View Answer
Ans : C
Explanation: Kotlin was developed by JetBrains.
2. Kotlin is a statically-typed programming language which runs on the?
A. JCM
B. JVM
C. JPM
D. JDM
View Answer
Ans : B
Explanation: Kotlin is a statically-typed programming language which runs on the JVM. It can be compiled either using Java source code and LLVM compiler.
3. Why you should switch to Kotlin from Java?
A. Kotlin language is quite simple compared to Java
B. It reduces may redundancies in code as compared to Java
C. Kotlin can offer some useful features which are not supported by Java
D. All of the above
View Answer
Ans : D
Explanation: Kotlin language is quite simple compared to Java. It reduces may redundancies in code as compared to Java. Kotlin can offer some useful features which are not supported by Java.
4. ____________ feature allows removing the risk of occurrence of NullPointerException in real time.
A. Null Risk
B. Null Safety
C. Null Pointer
D. All of the above
View Answer
Ans : B
Explanation: Null Safety feature allows removing the risk of occurrence of NullPointerException in real time. It is also possible to differentiate between nullable references and non-nullable references.
5. Kotlin is interoperable with Java because it uses JVM bytecode.
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, Kotlin is interoperable with Java because it uses JVM bytecode.Compiling it directly to bytecode helps to achieve faster compile time and makes no difference between Java and Kotlin for JVM.
6. How can you declare a variable in Kotlin?
A. value my_var: Char
B. value Char : my_var
C. my_var: Char
D. value my_var: Char
View Answer
Ans : D
Explanation: You declare a variable in Kotlin value my_var: Char
7. How many types of constructors available in Kotlin?
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : B
Explanation: Two types of constructors available in Kotlin are: Primary constructor and Secondary constructor
8. Which of the following is Use for reading contents of file to ByteArray?
A. bufferedReader()
B. readText()
C. readBytes()
D. readLines()
View Answer
Ans : C
Explanation: readBytes() is the extension methods Kotlin provides to java.io.File which is used for reading contents of file to ByteArray.
9. What is the use of data class in Kotlin?
A. extract the basic data types
B. delete the basic data types
C. present the basic data types
D. holds the basic data types
View Answer
Ans : D
Explanation: Data class holds the basic data types. It does not contain any functionality.
10. Is there any Ternary Conditional Operator in Kotlin like in Java?
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : B
Explanation: False, there is no ternary conditional operator in Kotlin language.
11. In Kotlin, ____________ is used when you know what functionalities a class should have.
A. exception class
B. inheritance class
C. abstraction class
D. None of the above
View Answer
Ans : C
Explanation: Abstraction is the most important concept of Objected Oriented Programming. In Kotlin, abstraction class is used when you know what functionalities a class should have. But you are not aware of how the functionality is implemented or if the functionality can be implemented using different methods.
12. What is the syntax for declaring a variable as volatile in Kotlin?
A. var x: Long? = null
B. Volatile var x: Long?
C. Volatile var x
D. Volatile var x: Long? = null
View Answer
Ans : D
Explanation: The syntax for declaring a variable as volatile in Kotlin is Volatile var x: Long? = null
13. Which of th following is used to compare two strings in Kotlin?
A. Using == operator
B. Using compareTo() extension function
C. Both A and B
D. None of the above
View Answer
Ans : C
Explanation: Both A and B is used to compare two strings in Kotlin.
14. Elvis Operator is used for handling null expectations in Kotlin.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: Elvis Operator is used for handling null expectations in Kotlin.
15. ____________ helps to iterate through a range.
A. And operator
B. Ranges operator
C. Or operator
D. Conditional operator
View Answer
Ans : B
Explanation: Ranges operator helps to iterate through a range. Its operator form is (..)
16. Which file extension is used to save Kotlin files?
A. .java
B. .kot
C. .kt
D. .kotlin
View Answer
Ans : C
Explanation: .kt or .kts extension is used to save Kotlin files.
17. All classes in Kotlin classes are by default?
A. public
B. sealed
C. abstract
D. final
View Answer
Ans : D
Explanation: All classes are final in Kotlin classes are by default
18. Can we migrate code from Java to Kotlin?
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, JetBrains IDEA provides an inbuilt tool to migrate code from java to Kotlin.
19. What is an immutable variable?
A. A variable that can be changed
B. A variable used for string interpolation
C. A variable that cannot change, read-only
D. None of the above
View Answer
Ans : C
Explanation: Immutable variable are a variable that cannot change, it is read-only.
20. Does Kotlin support primitive Datatypes?
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : B
Explanation: No, Kotlin does not provide support for primitive Data types like in Java.
Discussion