0
0
Kotlinprogramming~20 mins

Project structure and build basics in Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kotlin Gradle Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
Understanding Kotlin source folder structure

Given a typical Kotlin project, where should you place your main application code?

Asrc/main/kotlin
Bsrc/test/kotlin
Cbuild/kotlin
Dlib/kotlin
Attempts:
2 left
💡 Hint

Main application code goes in the source folder for production code, not tests or build outputs.

Predict Output
intermediate
1:30remaining
Gradle build script basics

What will be the output of running gradle tasks in a Kotlin project with a standard Gradle build?

ALists all available Gradle tasks including build, clean, and test
BCompiles the Kotlin source code
CRuns the main application
DDeletes the build directory
Attempts:
2 left
💡 Hint

Think about what the tasks command does in Gradle.

🔧 Debug
advanced
2:00remaining
Identify the build error in Gradle Kotlin DSL

Consider this snippet from a build.gradle.kts file:

plugins {
    kotlin("jvm") version "1.5.0"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib"))
    testImplementation("junit:junit:4.13.2")
}

application {
    mainClass.set("com.example.MainKt")
}

What error will Gradle report when trying to build?

AError: Missing repository declaration
BError: Kotlin version mismatch
CError: Unresolved reference: application
DNo error, build succeeds
Attempts:
2 left
💡 Hint

Check if the application block is recognized by Gradle without applying the right plugin.

Predict Output
advanced
1:30remaining
Output of Kotlin main function in Gradle project

Given this Kotlin main function in src/main/kotlin/com/example/Main.kt:

package com.example

fun main() {
    println("Hello from Kotlin Gradle project!")
}

What is the output when you run gradle run after configuring the application plugin correctly?

ABuild successful, no output
BHello from Kotlin Gradle project!
CError: main function not found
DGradle task 'run' not found
Attempts:
2 left
💡 Hint

Running gradle run executes the main function if configured properly.

🧠 Conceptual
expert
2:00remaining
Understanding Gradle build lifecycle phases

Which Gradle build phase is responsible for compiling Kotlin source code?

AExecution phase
BConfiguration phase
CInitialization phase
DTask execution phase
Attempts:
2 left
💡 Hint

Think about when tasks actually run during a Gradle build.