English
Review questions
Questions for self-check and exam preparation, grouped by course topic.
Topic 1. Kotlin and your first program
- What is the Kotlin language? What are its main advantages over Java? Explain the concepts of Kotlin/JVM and Kotlin Multiplatform.
- Explain the process of compiling and running a Kotlin program on the JVM platform. How does Kotlin interoperate with Java code?
- Describe the structure of a Kotlin program: the main function, packages, imports, and top-level files.
- How do you create a Kotlin project in IntelliJ IDEA with the Gradle build system? Explain the build.gradle.kts file and adding dependencies.
- What is the Git version control system? Explain the concepts of a repository, a commit, and a branch, and the basic Git commands.
- How do you work with a Git repository in IntelliJ IDEA? Which Gradle project files should be added to .gitignore?
Topic 2. Types, null safety, and control flow
- Explain declaring variables with val and var and type inference in Kotlin.
- What basic data types does Kotlin have? How are numeric types converted?
- What is null safety in Kotlin? Compare nullable and non-nullable types.
- Explain the safe call operator ?., the Elvis operator ?:, and the !! operator.
- What are smart casts? Explain the is and as? operators.
- Explain the when expression and compare it with the switch statement in Java.
- Explain the for, while, and do-while loops, ranges, and progressions (until, step, downTo).
Topic 3. Functions and strings
- Explain function declarations in Kotlin, functions with an expression body, and the Unit type.
- What are default parameters and named arguments? How do they replace function overloading?
- What are functions with a variable number of arguments (vararg), local functions, and infix functions?
- What are extension functions and extension properties? How do they work at the bytecode level?
- Explain string templates, multiline strings, and the main functions for working with strings.
- What is tail recursion and the tailrec modifier?
Topic 4. Exceptions, Result, and debugging
- How does exception handling work in Kotlin? Why does Kotlin have no checked exceptions?
- Explain try as an expression, the finally block, and the Nothing type.
- What are the Result type and the runCatching function? Compare them with exception handling.
- What are the require, check, and error functions for?
- How do you create a custom exception class in Kotlin?
- What debugging tools does IntelliJ IDEA provide for Kotlin programs?
Topic 5. Classes and objects
- Explain class declarations, the primary constructor, and init blocks in Kotlin.
- What are secondary constructors? How are they related to the primary constructor?
- What are properties in Kotlin? Explain custom get and set accessors and the field identifier.
- What is late property initialization (lateinit)?
- Explain the visibility modifiers public, private, protected, and internal.
- How do you organize code with packages and modules in a Kotlin project?
Topic 6. Inheritance and polymorphism
- Why are classes in Kotlin closed to inheritance by default? Explain the open and override modifiers.
- How do you call the base class constructor and methods using super?
- What are abstract classes and abstract class members?
- What are interfaces in Kotlin? Explain methods with a default implementation and interface properties.
- Compare abstract classes and interfaces. How do you resolve a conflict between identical methods from several interfaces?
- What is polymorphism? Give an example of a class hierarchy with overridden methods.
Topic 7. Data classes, enums, sealed
- What are data classes? Which methods does the compiler generate automatically?
- Explain the copy method and destructuring of data class objects.
- What are enumerations (enum class)? How do you add properties and methods to an enum?
- What are sealed classes and interfaces? How do they combine with the when expression?
- What is an object declaration? Compare singleton objects and anonymous objects.
- What are companion objects, and how do they replace Java's static members?
Topic 8. Operations and delegation
- How do you overload operators in Kotlin with the operator modifier? Give examples of the plus, get, and invoke functions.
- How do you overload the comparison and membership operators (compareTo, contains)?
- What are delegated properties? Explain the standard lazy delegate.
- Explain the Delegates.observable and Delegates.vetoable delegates and storing properties in a map.
- How do you create a custom property delegate (getValue, setValue)?
- What is class delegation (the by keyword)? Compare it with inheritance.
Topic 9. Generic programming
- Explain declaring generic classes and functions in Kotlin.
- What are type parameter constraints (upper bounds) and the where construct?
- What is variance? Explain the out and in modifiers at the declaration site.
- What are type projections and the star projection?
- What is type erasure? How do reified parameters in inline functions let you work around it?
- Explain generic extension functions using examples from the standard library.
Topic 10. Arrays and collections
- Describe the Kotlin collection hierarchy. Compare read-only and mutable collection interfaces.
- Explain working with List and MutableList and the listOf and mutableListOf functions.
- Explain Set and MutableSet. How does Kotlin compare set elements?
- Explain Map and MutableMap, Pair, and the to function.
- Compare Array and Kotlin collections. What are primitive type arrays (IntArray)?
- How does Kotlin map Java collections, and what are the specifics of collection interoperability with Java code?
Topic 11. Lambdas and sequences
- What are lambda expressions and function types in Kotlin? Explain the implicit parameter it.
- What are higher-order functions? Give examples of functions that accept and return functions.
- What are inline functions? How do they affect the performance of lambda expressions?
- Explain the collection operations filter, map, flatMap, groupBy, associate, and fold.
- What are sequences (Sequence)? Compare the lazy evaluation of sequences with collection operations.
- Explain the scope functions let, run, with, apply, and also.
- What are function and property references (:😃?
Topic 12. Files, serialization, and tests
- How do you read and write text files in Kotlin with the readText, readLines, writeText, and useLines functions?
- What is the use function for? How does it guarantee that resources are closed?
- What is the kotlinx.serialization library? How do you add its plugin and annotate classes with @Serializable?
- How do you serialize and deserialize objects to and from JSON? Explain the settings of the Json object.
- How do you write unit tests in Kotlin with kotlin.test and the JUnit Platform (JUnit 6)?
- How do you run tests in IntelliJ IDEA and with Gradle? What is test code coverage?
Topic 13. Coroutines and Flow
- What are coroutines? Compare coroutines with operating system threads.
- What are suspend functions? How does the compiler transform them (continuations)?
- Explain the coroutine builders launch, async, and runBlocking, and the await function.
- What is structured concurrency? Explain CoroutineScope, Job, and coroutine cancellation.
- Explain the coroutine dispatchers Dispatchers.Default, Dispatchers.IO, and Dispatchers.Main, and the withContext function.
- How do you handle exceptions in coroutines? What are SupervisorJob and CoroutineExceptionHandler?
- What are asynchronous Flow streams? Explain flow operators, StateFlow, and SharedFlow.
Topic 14. Databases with Exposed
- Explain the basic concepts of relational databases and SQL: tables, keys, relationships, and the SELECT, INSERT, UPDATE, and DELETE statements.
- How do you create a local SQLite database? Compare its deployment with PostgreSQL.
- What is the Exposed library? How do you connect to an SQLite database and run transactions?
- How do you describe tables and run queries with the Exposed DSL?
- Explain the DAO approach in Exposed: Entity entities and EntityClass classes.
- How do you describe relationships between tables in Exposed and protect against SQL injection?
Topic 15. Compose Multiplatform
- What is Compose Multiplatform? Compare the declarative and imperative approaches to building a user interface.
- What are composable functions (@Composable)? How does recomposition happen?
- Explain the basic Compose components: Text, Button, TextField, and Image.
- Explain layout in Compose: Column, Row, Box, and Modifier.
- How do you store component state with remember and mutableStateOf?
- What is state hoisting and unidirectional data flow?
- How do you display lists with LazyColumn and style the interface with Material Design 3?
Topic 16. MVVM and navigation
- Describe the MVVM architecture in Compose Multiplatform applications. What is the role of the ViewModel class?
- How do you pass state from a ViewModel to the interface with StateFlow and collectAsState?
- How do you organize navigation between screens in Compose Multiplatform?
- How do you run database queries in coroutines without blocking the interface?
- How do you organize a data access layer (repository) in a Compose Multiplatform application?
- How do you build and distribute a Compose Multiplatform desktop application?