0% found this document useful (0 votes)
20 views4 pages

Kotlin Interview Questions

This document provides a comprehensive list of Kotlin interview questions and answers in both Urdu and English, aimed at individuals preparing for Kotlin developer interviews. Each question includes a brief explanation and example code to illustrate the concepts. Topics covered include Kotlin's features, null safety, data classes, higher-order functions, coroutines, and more.

Uploaded by

humayunakbar841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Kotlin Interview Questions

This document provides a comprehensive list of Kotlin interview questions and answers in both Urdu and English, aimed at individuals preparing for Kotlin developer interviews. Each question includes a brief explanation and example code to illustrate the concepts. Topics covered include Kotlin's features, null safety, data classes, higher-order functions, coroutines, and more.

Uploaded by

humayunakbar841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Kotlin Interview Questions with Answers (Urdu + English)

Yeh document un logon ke liye hai jo Kotlin developer ke interview ki tayari kar rahe hain. Har question ke
sath short explanation aur example code bhi diya gaya hai.

1. Kotlin kya hai aur iski khasiyat kya hain?

English: What is Kotlin and what are its key features? Answer: Kotlin aik statically-typed programming
language hai jo JVM, Android, JS aur Native pe run hoti hai. Features: Null safety, extension functions,
coroutines, concise syntax, Java interoperability.

val message: String = "Hello Kotlin"


println(message)

2. val aur var mein kya farq hai?

Answer: val se immutable variable banta hai (change nahi hota), jabke var se mutable (changeable).

val name = "Ali" // cannot be reassigned


var age = 25
age = 26

3. Kotlin mein null safety kaise implement hoti hai?

Answer: ? nullable types define karta hai. ?. , ?: , !! operators se null handle hota hai.

val name: String? = null


val length = name?.length ?: 0

4. Data class kya hoti hai?

Answer: Special class jo data hold karti hai. Automatic methods generate hoti hain: toString() ,
equals() , etc.

1
data class User(val name: String, val age: Int)
val user = User("Ali", 30)

5. Higher-order functions kya hoti hain?

Answer: Functions jo function ko parameter ya return ke tor par use karti hain.

fun operate(a: Int, b: Int, op: (Int, Int) -> Int): Int = op(a, b)
val sum = operate(2, 3) { x, y -> x + y }

6. Lambda expressions kya hain?

Answer: Inline anonymous functions hoti hain.

val multiply = { a: Int, b: Int -> a * b }


println(multiply(3, 4))

7. Sealed classes ka use kya hai?

Answer: Restricted class hierarchy. Helpful in when statements.

sealed class Result


class Success(val data: String): Result()
class Error(val message: String): Result()

8. Companion object kya hota hai?

Answer: Static members define karne ke liye use hota hai.

class Utils {
companion object {
fun greet() = "Hello!"
}
}

2
9. Difference between == and === in Kotlin?

Answer: == value compare karta hai. === reference.

val a = "Hi"
val b = "Hi"
println(a == b) // true
println(a === b) // true or false depending on memory

10. Extension functions kya hoti hain?

Answer: Kisi class mein bina modify kiye naya function add karna.

fun [Link](): Char = this[0]


println("Kotlin".firstChar())

11. Kotlin Coroutines kya hain?

Answer: Asynchronous programming ke liye lightweight threads.

[Link] {
delay(1000L)
println("Coroutine Running")
}

12. Difference between List, MutableList and Array

Answer:

• List : read-only
• MutableList : changeable
• Array : fixed-size

val list = listOf("A", "B")


val mList = mutableListOf("X")
[Link]("Y")
val arr = arrayOf(1, 2)

3
13. Android mein Kotlin kaise use hota hai?

Answer: Android ke har component mein Kotlin use hota hai (UI, Logic, Background).

[Link] {
[Link] = "Clicked!"
}

14. LiveData kya hoti hai?

Answer: Observable data holder that is lifecycle-aware.

val liveData = MutableLiveData<String>()


[Link](this) { data ->
println("Updated: $data")
}

15. ViewModel ka role kya hai?

Answer: UI data ko lifecycle ke according manage karta hai.

class MyViewModel: ViewModel() {


val data = MutableLiveData<String>()
}

Yeh questions Kotlin interviews mein frequently poochay jaate hain. Aap chahein to mock test ya quiz
format mein bhi convert karwa sakte hain.

You might also like