Bird
0
0

What will be the output of running the following Gradle task command if the project has no errors?

medium📝 Predict Output Q5 of 15
Kotlin - Basics and JVM Runtime
What will be the output of running the following Gradle task command if the project has no errors? Task in build.gradle.kts: tasks.register("hello") { doLast { println("Hello from Gradle task!") } } Command: ./gradlew hello
ATask 'hello' not found
BHello from Gradle task!
CBuild failed due to syntax error
DNo output, task does nothing
Step-by-Step Solution
Solution:
  1. Step 1: Understand task registration

    The task named "hello" prints a message when run.
  2. Step 2: Running ./gradlew hello executes the task

    The println inside doLast block outputs the message to console.
  3. Final Answer:

    Hello from Gradle task! -> Option B
  4. Quick Check:

    Gradle task output = Hello from Gradle task! [OK]
Quick Trick: Gradle tasks print inside doLast when executed [OK]
Common Mistakes:
MISTAKES
  • Assuming task is missing or not registered
  • Expecting no output from task
  • Confusing syntax error with correct code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes