Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Gradle Interview questions and Answer Part 1

What are the parts of the task lifecycle?

A. Configuration, Execution
B. Initialization, Configuration, Execution
C. Initialization, Configuration, Execution, Finalization
D. Execution

Ans: B. Initialization, Configuration, Execution

If I want to run a java application which plugin do I use?

A. java
B. run
C. application
D. java-runner

Ans: C. application

What does the wrapper task do?

A. Ensures that all developers use the same version of Gradle to build the code
B. Wraps up the code so that any exceptions are caught
C. Wraps gradle so it can be used from an IDE such as Eclipse
D. Installs an extra set of Java tasks to make testing easier

Ans: A. Ensures that all developers use the same version of Gradle to build the code

What is the syntax for filtering tests in gradle?

A. add a test { filter {} } closure
B. you have to run all the tests, you cannot filter
C. add the test-filter plugin
D. build only the tests you want to run

Ans: A. add a test { filter {} } closure

What does taskA.finalizedBy taskB do?

A. Causes taskB to run before taskA
B. Causes taskA and taskB to run in parallel
C. Nothing, this is not yet available in Gradle
D. Causes taskB to run after taskA

Ans: D. Causes taskB to run after taskA

When you taskA.mustRunAfter taskB

A. When you taskA.mustRunAfter taskB
B. taskA runs after taskB only if both tasks are scheduled to run
C. taskB always runs after

Ans: B. taskA runs after taskB only if both tasks are scheduled to run

When you call doLast on a task twice passing different closures what happens?

A. Only the first closure is executed
B. Only the last closure is executed
C. Neither closure is executed, it is an error
D. Both closures are executed

Ans: D. Both closures are executed

How do you add the java plugin?

A. Do nothing. The plugin is always enabled
B. apply java plugin
C. java ‘plugin’
D. apply plugin ‘java’

Ans: D. apply plugin ‘java’

When copying files you can use which method to replace text?

A. expand
B. replace
C. regex
D. insert

Ans: A. expand

Which of the following is valid gradle syntax to add a compile dependency on junit?

A. compile name=junit version=4.1.2
B. compile ‘junit:4.12’
C. compile ‘junit:version:4.1.12’
D. compile ‘junit:junit:4.1.12’

Ans: D. compile ‘junit:junit:4.1.12’

What is the syntax for defining a repository in Gradle?

A. use jcenter()
B. repositories: jcenter()
C. repository: jcenter()
D. repositories { jcenter() }

Ans: D. repositories { jcenter() }

In a multi project build which two files do I need to add to the top level project?

A. build.gradle and build.settings
B. multi.gradle and settings.gradle
C. build.gradle and settings.properties
D. build.gradle and settings.gradle

Ans: D. build.gradle and settings.gradle

How do you declare a task?

A. Task.withName taskName
B. Task taskName
C. Task: taskName
D. taskName: Task

Ans: B. Task taskName

If you use the gradle-testsets-plugin how do you add an integrationTest sourceset in gradle?

A. testSets { integrationTest { dirName=’myDir’ } }
B. testSets { dirName=’myDir’}
C. testSets { integrationTest = ‘myDir’ }
D. integrationTest { dirName=’myDir’}

Ans: A. testSets { integrationTest { dirName=’myDir’ } }

When you use the << syntax which method on the task is executed?

A. last
B. first
C. doFirst
D. doLast

Ans: D. doLast

How do I tell the plugin where my Java files are if I don’t follow the Gradle convention?

A. use a sources closure
B. set a source property in the gradle build file
C. use a sourceSets closure
D. set a source property on the command line of the gradle build tool

Ans: C. use a sourceSets closure

How do you declare a typed task?

A. task copyImages (type: Copy)
B. task copyImages (type: Copy)
C. Copy copyImages

Ans: A. task copyImages (type: Copy)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

What is Gradle and use cases of Gradle?

What is Gradle? Gradle is an open-source build automation tool that is designed to be flexible, powerful, and highly customizable. It is often used for building, testing,…

Read More

What is Gradle and How it works? An Overview and Its Use Cases?

What is Gradle? Gradle is a popular choice for Java developers who want flexibility and performance in a build automation tool. Gradle is a modern automation tool…

Read More

Top 50 interview questions and answers of Gradle

Short description about Gradle Gradle is an open-source build automation tool that is designed to be flexible enough to build almost any type of software. Moving to…

Read More

Top Gradle interview questions and answers

What is Gradle build tool? Gradle is a build automation tool based on Groovy and Kotlin. It’s open-source and flexible enough to build almost any type of software….

Read More

What is settings.gradle in Gradle?

A gradle build has three important files. build.gradle, gradle.properties and settings.gradle Gradle build lifecycle consist of three phases: initialization, configuration, and execution. settings.gradle get evaluated in the…

Read More

What is Gradle DAG (Directed Acyclic Graph)?

What is DAG (Directed Acyclic Graph) In computer science and mathematics, a directed acyclic graph (DAG) is a graph that is directed and without cycles connecting the…

Read More