# Kotlin interview questions
### Во что компилируется extension?
В статический метод в котором первым параметром принимается класс для которого делают extension
### What is difference between data class and normal class?
Data class generates
- hashCode()
- toString()
- copy()
- equals()
- getters and setters
- componentN()
- synthetic method copy$default
### What is destructing declaration?
``` Kotlin
val (name, age) = user1
```
### If we create this snipped of code, what will it return and why?
```Kotlin
data class Person(val name: String){
var age: Int = 0
}
fun main(){
val firstPerson = Person("Peter")
val secondPerson = Person("Peter")
firstPerson.age = 18
secondPerson.age = 20
println("${firstPerson == secondPerson}")
}
```
```equals()``` overrides only the primary constructor
> “If there are explicit implementations of equals(), hashCode() or toString()in the data class body or final implementations in a superclass, then these functions are not generated, and the existing implementations are used.”
### What is Kotlin Coroutines?
Coroutines are a Kotlin feature that converts async callbacks for long-running tasks, such as database or network access, into sequential code.
### What is the difference between val and const in Kotlin?
const are compile time constants. val and runtime. For val constants the one can call complex function computation. For consts - cannot. Also const will not work with constructions invocation.
``` Kotlin
val foo1 = complexFunction() // Ok
const val foo2 = complexFunction() // Not Ok
```
---
## Resources
1. https://career.guru99.com/top-25-kotlin-interview-questions-and-answers/
2. https://stackoverflow.com/questions/37595936/what-is-the-difference-between-const-and-val