Kotlin Sorting out interview questions
1, What is? kotlin
kotlin By JetBrains Developed static type programming language , Run in JVM upper .
2, Why Kotlin language
Kotlin Concise and efficient language , There is not so much redundant code , And it's empty and safe .
3, Explain extension function
extension Function is used to class Expand , Not from class derive
4,kotlin Empty security in null safety What do you mean?
The feature of null security is to avoid null pointer exceptions , It can also be used to distinguish between null and non null references .
5,kotlin Why and java Interoperability
Because for jvm Generally speaking, they are the same after compilation , After compilation byte code stay jvm Run on
6,kotlin Is there a ternary operator in
7,kotlin How to declare a variable in
var name: String
8,kotlin How many constructors are there
two types , One is primary Constructor , One is secondary Constructor
9, Say it kotlin Medium for Java.io.file Extension method of
10,kotlin How to handle null exceptions
use elvis The operator handles null exceptions ?： , ?.
11, What are the characteristics ,kotlin Yes and java No,
null safety,operator overloading,coroutines, range expressions, smart cast,
12,kotlin The role of data classes in
Data classes contain basic data types , However, it does not contain any function functions
13, Can put java Code conversion to kotlin Code
Can be in AndroidStudio perhaps JetBrains Intermediate conversion
14,kotlin allow macros Do you
kotlin Macros are not supported
15,kotlin Default behavior of class
kotlin The default is final of . because kotlin Support multiple class inheritance , Open classes cost more than final Class is much higher
16,kotlin Is the original data type supported
kotlin Raw data type is not supported
17, What is? range Operator
range The operator is used to traverse a range , Represented by two points
for（i in 1..5）
18,kotlin Of standards java Do libraries and classes provide additional functionality
kotlin The program is standard java On virtual machines , therefore kotlin and java There is no difference at this level ,java You can also directly kotlin Run in program
19, stay kotlin Define a volatile variable
volatile var x: Long? = null
20,kotlin What is the role of abstraction in
Abstract is the most important concept of object-oriented programming . Characteristics of abstract classes ： Do you know what this class will do , But I don't know how to realize these functions and what functions to realize .
21,kotlin How to compare two strings
22, What is this code for
bar As a function , Receiving an expression as an argument , This expression prints a line of string
23,kotlin Higher order function