Explore the fundamentals of Kotlin Multiplatform (KMP), sharing code across platforms, and setting up a Kotlin Multiplatform Mobile (KMM) project. These 30 MCQs cover all the key areas of multiplatform development.
MCQs on Multiplatform Development
1. Kotlin Multiplatform Basics
What is Kotlin Multiplatform (KMP) primarily used for? a) Creating Android apps only b) Sharing code across multiple platforms c) Writing platform-specific code only d) Building web applications only
Which of the following is a key feature of Kotlin Multiplatform? a) Cross-platform UI components b) Shared business logic across platforms c) Native Android support only d) It requires separate languages for each platform
Which platforms are supported by Kotlin Multiplatform? a) Android, iOS, Web, JVM b) Android, Linux, Windows c) Only Android and iOS d) Android, iOS, Web, Desktop, JVM, Linux
How does Kotlin Multiplatform achieve code sharing? a) By using Kotlin only for UI code b) Through a common codebase for business logic c) By requiring platform-specific code for each functionality d) Through a shared UI framework
What is the purpose of Kotlin Multiplatform Mobile (KMM)? a) To share code between Android and iOS apps b) To create Android apps only c) To optimize the performance of Android apps d) To develop web applications
Which of the following is not a supported target in Kotlin Multiplatform? a) JVM b) JavaScript c) Objective-C d) Android
What is the common module in Kotlin Multiplatform? a) A module for platform-specific code b) A module that holds shared code between platforms c) A module for testing only d) A module for UI components
What is the role of expect and actual keywords in Kotlin Multiplatform? a) expect defines platform-specific functionality, actual implements it b) expect is used for testing, actual for production code c) expect is used to define functions, actual to implement them in a common codebase d) expect defines platform-specific UI elements
In Kotlin Multiplatform, how are platform-specific APIs accessed? a) Using the expect keyword only b) By writing platform-specific code directly c) Through the actual implementation d) By using cross-platform libraries
What is a major advantage of Kotlin Multiplatform in mobile app development? a) It allows for shared UI code b) It supports shared business logic across Android and iOS c) It works only for Android apps d) It automatically generates platform-specific code
2. Sharing Code Between Platforms
In Kotlin Multiplatform, how do you share code between Android and iOS? a) By using platform-specific frameworks b) By writing separate code for each platform c) Through a shared common module d) By using separate Kotlin versions for each platform
Which of the following does Kotlin Multiplatform allow you to share between platforms? a) UI components b) Business logic c) Platform-specific libraries d) Platform-specific APIs
How are shared code modules created in Kotlin Multiplatform? a) By using platform-specific Gradle files b) Through a common module in the project structure c) By writing shared code directly in the Android module d) By creating separate classes for each platform
Can Kotlin Multiplatform share dependencies across Android and iOS? a) Yes, using shared libraries b) No, only Android dependencies are shared c) Yes, but only for business logic d) No, each platform must have its own dependencies
What is one of the challenges in sharing code between Android and iOS with Kotlin Multiplatform? a) UI code cannot be shared b) The code must be rewritten for each platform c) It is difficult to handle platform-specific dependencies d) Code sharing is only possible between Android and web platforms
In Kotlin Multiplatform, which part of the app can be shared across platforms? a) Entire app, including UI b) Only the logic and data models c) Shared business logic and network calls d) Only the network calls
Which Kotlin feature is used to define platform-specific behavior while sharing code? a) expect and actual b) in and out c) sealed classes d) reified types
How do you test shared code in Kotlin Multiplatform? a) By running tests only on Android b) By using shared testing libraries c) By writing tests separately for each platform d) By using a special test module for iOS
Which file defines dependencies for Kotlin Multiplatform projects? a) settings.gradle b) build.gradle.kts c) config.gradle d) dependency.gradle
What is an important consideration when sharing code between platforms in Kotlin Multiplatform? a) Platform-specific UI code should be avoided b) Only basic data models can be shared c) All shared code should be rewritten for each platform d) Platform-specific code cannot be tested
3. Setting up a KMM Project
What is the first step in setting up a Kotlin Multiplatform Mobile (KMM) project? a) Configure a Gradle file for Android b) Initialize a shared module for business logic c) Create platform-specific UI components d) Set up an iOS project with Xcode
Which IDE is commonly used to set up KMM projects? a) IntelliJ IDEA b) Eclipse c) NetBeans d) Xcode
What is the file that contains platform-specific configurations in a KMM project? a) shared.kt b) build.gradle.kts c) config.gradle d) platforms.gradle
How do you add iOS as a target in a KMM project? a) By adding the ios() target in the Gradle configuration b) By configuring an iOS project in Xcode c) By setting up a dependency in the settings.gradle file d) By using the expect keyword for iOS
Which plugin is required for a Kotlin Multiplatform Mobile (KMM) project? a) kotlin-multiplatform b) kotlin-android c) kotlin-ios d) kotlin-mpp
In a KMM project, what does the commonMain source set contain? a) Platform-specific code b) Shared code that can be used across platforms c) Android-specific code d) iOS-specific code
Which of the following is true about building a KMM project? a) You can build a KMM project without an Android app b) You need separate build configurations for each platform c) KMM projects only work with Android d) All dependencies must be shared across platforms
How do you manage dependencies for shared code in a KMM project? a) By adding dependencies to the commonMain source set b) By configuring each platform’s dependencies separately c) By using a shared .gradle file d) By adding dependencies in the iOSMain source set
Which Gradle task is used to build a Kotlin Multiplatform Mobile project? a) gradle build b) ./gradlew build c) gradle assemble d) ./gradlew assemble
What is the purpose of the iosMain source set in a KMM project? a) To hold platform-independent code b) To define iOS-specific logic and code c) To test iOS-specific functionality d) To share code between iOS and Android
Answers Table
Qno
Answer (Option with Text)
1
b) Sharing code across multiple platforms
2
b) Shared business logic across platforms
3
d) Android, iOS, Web, Desktop, JVM, Linux
4
b) Through a common codebase for business logic
5
a) To share code between Android and iOS apps
6
c) Objective-C
7
b) A module that holds shared code between platforms
8
a) expect defines platform-specific functionality, actual implements it
9
c) Through the actual implementation
10
b) It supports shared business logic across Android and iOS
11
c) Through a shared common module
12
b) Business logic
13
b) Through a common module in the project structure
14
a) Yes, using shared libraries
15
c) It is difficult to handle platform-specific dependencies
16
c) Shared business logic and network calls
17
a) expect and actual
18
b) By using shared testing libraries
19
b) build.gradle.kts
20
a) Platform-specific UI code should be avoided
21
b) Initialize a shared module for business logic
22
a) IntelliJ IDEA
23
b) build.gradle.kts
24
a) By adding the ios() target in the Gradle configuration
25
a) kotlin-multiplatform
26
b) Shared code that can be used across platforms
27
b) You need separate build configurations for each platform
28
a) By adding dependencies to the commonMain source set