Top 25 Kotlin Interview Questions and Answers


) Explain the use of data class in Kotlin?



Yüklə 64,62 Kb.
Pdf görüntüsü
səhifə3/3
tarix25.03.2023
ölçüsü64,62 Kb.
#90047
1   2   3
top-25-kotlin-interview-questions-and-answers

15) Explain the use of data class in Kotlin?
Data class holds the basic data types. It does not contain any functionality.
16) Can we migrate code from Java to Kotlin?
Yes, JetBrains IDEA provides an inbuilt tool to migrate code from java to Kotlin.
17) Does Kotlin allow macros?
No. Kotlin does not offer support for macros because the developers of Kotlin find it difficult to
include it in the language.
18) Tell me the default behavior of Kotlin classes?
In Kotlin all classes are final by default. That’s because Kotlin allows multiple inheritances for
classes, and an open class is more expensive than a final class.
19) Does Kotlin support primitive Datatypes?
No, Kotlin does not provide support for primitive Data types like in Java.
20) What is Ranges operator in Kotlin?
Ranges operator helps to iterate through a range. Its operator form is (..) For Example
[crayon-5f2d067b7b062416738577/]
It will print from 1 to 15 in output.
21) Can Kotline offer any additional functionality for standard Java packages or standard
Java classes?
Kotlin programs can run on standard JVM like any another compiled Java code. It allows JVM to
compile any program to byte-code. It is accessible using Java Virtual Machine. Therefore, Kotlin
is almost similar to Java. Moreover, Kotlin applications can be built with parts of Java code.
22) Give a syntax for declaring a variable as volatile in Kotlin? 
[crayon-5f2d067b7b068857010747/]
3 / 4


https://career.guru99.com/
23) What is the use of abstraction in Kotlin?
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.
24) How to compare two strings in Kotlin?
Compares string in Kotlin are possible in the following ways:
1. Using "==" operator:
You can use ah operator for comparison of two string. In Kotlin == operator is used.
2. Using compareTo() extension function
Syntax of compareTo() function is given below :
[crayon-5f2d067b7b06a545229312/]
Another code example
[crayon-5f2d067b7b06b754202090/]
25) What does this code do?
[crayon-5f2d067b7b06c006213042/]
The code passes lambda function that prints "Guru99!" as an argument into function bar()
4 / 4

Yüklə 64,62 Kb.

Dostları ilə paylaş:
1   2   3




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin