Kotlin Quiz

Test your knowledge. Select answers, then submit to see your score and explanations.

1. Which keyword declares a read-only variable in Kotlin?

Kotlin Basics

2. What does println() do?

Kotlin Basics

3. Who created Kotlin?

Kotlin Basics

4. What is the entry point of a Kotlin program?

Kotlin Basics

5. Which of these is NOT a valid Kotlin data type?

Kotlin Basics

6. What does the ? after a type mean in Kotlin?

Null Safety

7. What does the Elvis operator ?: do?

Null Safety

8. What does name?.length return when name is null?

Null Safety

9. What does 1..5 create in Kotlin?

Control Flow

10. Which Kotlin construct replaces switch from Java?

Control Flow

11. What is a default argument in Kotlin?

Functions

12. What does tailrec do in Kotlin?

Functions

13. What does listOf() return?

Collections

14. What does filter {} do on a collection?

Collections

15. What does a data class auto-generate?

OOP

16. What keyword makes a Kotlin class inheritable?

OOP

17. What is a sealed class in Kotlin?

OOP

18. What does it refer to in a Kotlin lambda?

Lambdas

19. What does delay() do in a Kotlin coroutine?

Coroutines

20. What is the difference between launch and async?

Coroutines

21. What is a cold Flow in Kotlin?

Flow

22. What does reified mean in a Kotlin inline function?

Generics

23. What symbol is used for string templates in Kotlin?

Kotlin Basics

24. What is a companion object in Kotlin?

OOP

25. What does !! do in Kotlin?

Null Safety

26. Which is the correct way to declare a mutable variable?

Kotlin Basics

27. What does the .. operator create?

Kotlin Basics

28. How do you embed a variable in a string?

Strings

29. What does break do inside a for loop?

Control Flow

30. What does continue do in a loop?

Control Flow

31. What is a single-expression function?

Functions

32. What does the inline keyword do on a function?

Functions

33. What does map {} do on a list?

Collections

34. What does setOf() create?

Collections

35. How do you get a value from a map by key?

Collections

36. What is an object declaration in Kotlin?

OOP

37. What does override mean on a function?

OOP

38. What is an interface in Kotlin?

OOP

39. What is the type of { x: Int -> x * 2 }?

Lambdas

40. What does apply return?

Scope Functions

41. What does with do?

Scope Functions

42. Does Kotlin have checked exceptions like Java?

Exceptions

43. What does finally do in try/catch?

Exceptions

44. What is type erasure?

Generics

45. What is a coroutine scope?

Coroutines

46. What does await() do on a Deferred?

Coroutines

47. What is StateFlow used for?

Flow

48. Which file extension is used for Kotlin source?

Kotlin Basics

49. What is a primary constructor in Kotlin?

OOP

50. What is a trailing lambda?

Lambdas

51. Which dispatcher should you use for disk or network I/O?

Coroutines

52. What does coroutineScope guarantee?

Coroutines

53. When should you use SharedFlow instead of StateFlow?

Flow

54. How do you access a companion object constant?

OOP

55. What does enum class create?

OOP

56. What is a top-level object declaration?

OOP