MCQs on Multiplatform Development | Kotlin

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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. Which of the following is not a supported target in Kotlin Multiplatform?
    a) JVM
    b) JavaScript
    c) Objective-C
    d) Android
  7. 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
  8. 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
  9. 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
  10. 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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. Which file defines dependencies for Kotlin Multiplatform projects?
    a) settings.gradle
    b) build.gradle.kts
    c) config.gradle
    d) dependency.gradle
  10. 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

  1. 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
  2. Which IDE is commonly used to set up KMM projects?
    a) IntelliJ IDEA
    b) Eclipse
    c) NetBeans
    d) Xcode
  3. 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
  4. 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
  5. Which plugin is required for a Kotlin Multiplatform Mobile (KMM) project?
    a) kotlin-multiplatform
    b) kotlin-android
    c) kotlin-ios
    d) kotlin-mpp
  6. 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
  7. 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
  8. 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
  9. Which Gradle task is used to build a Kotlin Multiplatform Mobile project?
    a) gradle build
    b) ./gradlew build
    c) gradle assemble
    d) ./gradlew assemble
  10. 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

QnoAnswer (Option with Text)
1b) Sharing code across multiple platforms
2b) Shared business logic across platforms
3d) Android, iOS, Web, Desktop, JVM, Linux
4b) Through a common codebase for business logic
5a) To share code between Android and iOS apps
6c) Objective-C
7b) A module that holds shared code between platforms
8a) expect defines platform-specific functionality, actual implements it
9c) Through the actual implementation
10b) It supports shared business logic across Android and iOS
11c) Through a shared common module
12b) Business logic
13b) Through a common module in the project structure
14a) Yes, using shared libraries
15c) It is difficult to handle platform-specific dependencies
16c) Shared business logic and network calls
17a) expect and actual
18b) By using shared testing libraries
19b) build.gradle.kts
20a) Platform-specific UI code should be avoided
21b) Initialize a shared module for business logic
22a) IntelliJ IDEA
23b) build.gradle.kts
24a) By adding the ios() target in the Gradle configuration
25a) kotlin-multiplatform
26b) Shared code that can be used across platforms
27b) You need separate build configurations for each platform
28a) By adding dependencies to the commonMain source set
29b) ./gradlew build
30b) To define iOS-specific logic and code

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top