Top 50 Gradle Interview Questions with Answers

Gradle Interview Questions with Answers

1. What is Gradle?

A. Source code editor
B. Build automation tool
C. Virtual machine
D. Version control system

Answer: B

2. Why do we use Gradle?

A. To debug code
B. To manage dependencies
C. To write code
D. To execute unit tests

Answer: B

3. What is the latest version of Gradle?

A. 5.0
B. 6.0
C. 6.1
D. 7.0

Answer: D

4. What is a build script in Gradle?

A. A script that runs unit tests
B. A script that executes the build process
C. A script that manages dependencies
D. A script that creates release notes

Answer: B

5. What is the Gradle wrapper?

A. A tool used to download and install Gradle
B. A module used to manage dependencies
C. A command-line tool used to run Gradle
D. A plugin used to analyze code quality

Answer: A

6. What is the difference between a task and a project in Gradle?

A. A task is a set of related projects
B. A project is a set of related tasks
C. A task is an action that Gradle performs
D. A project is a folder containing Gradle files

Answer: C

7. What is a plugin in Gradle?

A. A tool used to download and install Gradle
B. A module used to manage dependencies
C. A command-line tool used to run Gradle
D. A module used to add functionality to Gradle

Answer: D

8. How do you declare a dependency in Gradle?

A. By adding it to the settings.gradle file
B. By adding it to the build.gradle file
C. By adding it to the gradle.properties file
D. By adding it to the pom.xml file

Answer: B

9. What is the difference between compile and runtime dependencies in Gradle?

A. Compile dependencies are necessary for compiling the code, while runtime dependencies are only needed when the code is run
B. Runtime dependencies are necessary for compiling the code, while compile dependencies are only needed when the code is run
C. Compile dependencies are only needed when the code is run, while runtime dependencies are necessary for compiling the code
D. There is no difference between compile and runtime dependencies in Gradle

Answer: A

10. How do you exclude a transitive dependency in Gradle?

A. By adding it to the settings.gradle file
B. By adding it to the build.gradle file
C. By adding it to the gradle.properties file
D. By adding it to the pom.xml file

Answer: B

11. What is a Gradle wrapper task used for?

A. To download and install Gradle on the local machine
B. To manage the dependencies of a project
C. To execute unit tests
D. To automate the build process

Answer: A

12. What is a Gradle subproject?

A. A separate project that can be built independently
B. A module used to manage dependencies
C. A command-line tool used to run Gradle
D. A plugin used to add functionality to Gradle

Answer: A

13. How do you run a Gradle task?

A. By running the gradle command followed by the task name
B. By running the java command followed by the task name
C. By running the run command followed by the task name
D. By running the execute command followed by the task name

Answer: A

14. Which of the following is not a feature of Gradle?

A. Incremental build
B. Build caching
C. Cross-platform support
D. Code coverage analysis

Answer: D

15. What is the difference between Gradle and Maven?

A. Gradle is a build automation tool, while Maven is a version control system
B. Maven is faster than Gradle
C. Gradle is easier to use than Maven
D. Gradle uses Groovy as its scripting language, while Maven uses XML

Answer: D

16. How do you create a new Gradle project?

A. By running the gradle init command
B. By running the gradle create command
C. By running the gradle new command
D. By running the gradle project command

Answer: A

17. What is a Gradle plugin repository?

A. A repository where Gradle is hosted
B. A repository where Gradle plugins are hosted
C. A repository where Gradle projects are hosted
D. A repository where Gradle wrappers are hosted

Answer: B

18. Which file is used to configure the Gradle build process?

A. settings.gradle
B. build.gradle
C. gradle.properties
D. pom.xml

Answer: B

19. What is the Gradle build lifecycle?

A. Initialization, configuration, execution, cleanup
B. Configuration, execution, cleanup
C. Initialization, execution, cleanup
D. Configuration, initialization, execution

Answer: A

20. How do you add a custom task in Gradle?

A. By adding it to the settings.gradle file
B. By adding it to the build.gradle file
C. By adding it to the gradle.properties file
D. By adding it to the pom.xml file

Answer: B

21. What is the Gradle init task used for?

A. To initialize a new Gradle project
B. To create a new Gradle task
C. To download and install Gradle
D. To clean the build directory

Answer: A

22. What is the Gradle daemon?

A. A module used to manage dependencies
B. A command-line tool used to run Gradle
C. A plugin used to analyze code quality
D. A background process that runs Gradle builds

Answer: D

23. How do you specify the Java version used by Gradle?

A. By adding it to the settings.gradle file
B. By adding it to the build.gradle file
C. By adding it to the gradle.properties file
D. By adding it to the pom.xml file

Answer: B

24. What is the difference between a task rule and a task type in Gradle?

A. A task rule is a way to create tasks dynamically, while a task type is a predefined task
B. A task type is a way to create tasks dynamically, while a task rule is a predefined task
C. There is no difference between a task rule and a task type in Gradle
D. A task rule and a task type are the same thing in Gradle

Answer: A

25. How do you configure a Gradle task?

A. By adding properties to the task in the build script
B. By running the gradle configure task command
C. By modifying the gradle.properties file
D. By modifying the pom.xml file

Answer: A

26. What is a Gradle build cache?

A. A cache used to store compiled code in memory
B. A cache used to store build artifacts for reuse
C. A cache used to store Gradle configuration files
D. A cache used to store Gradle plugin dependencies

Answer: B

27. What is a Gradle composite build?

A. A build consisting of multiple Gradle tasks
B. A build consisting of multiple Gradle projects
C. A build consisting of multiple Gradle plugins
D. A build consisting of multiple Gradle builds

Answer: B

28. How do you declare a repository in Gradle?

A. By adding it to the settings.gradle file
B. By adding it to the build.gradle file
C. By adding it to the gradle.properties file
D. By adding it to the pom.xml file

Answer: B

29. What is a Gradle build script block?

A. A block of code that defines a task
B. A block of code that defines a plugin
C. A block of code that configures a repository
D. A block of code that runs during the build process

Answer: A

30. What is a Gradle multiproject?

A. A single Gradle project that consists of multiple modules
B. Multiple Gradle projects that are built together
C. A module used to manage dependencies
D. A plugin used to add functionality to Gradle

Answer: B

31. What is a Gradle module?

A. A separate project that can be built independently
B. A plugin used to analyze code quality
C. A command-line tool used to run Gradle
D. A module used to manage dependencies

Answer: D

32. What is a Gradle root project?

A. The main Gradle project in a multiproject build
B. The Gradle module that contains the source code
C. A plugin used to manage dependencies
D. A module that uses Gradle as its build tool

Answer: A

33. What is the Gradle configuration phase?

A. The phase of the build where Gradle configures the tasks
B. The phase of the build where Gradle executes the tasks
C. The phase of the build where Gradle cleans up after the tasks
D. The phase of the build where Gradle initializes the tasks

Answer: A

34. Why is incremental build important in Gradle?

A. It speeds up the build process
B. It reduces the memory usage of the build process
C. It makes the build more reliable
D. It makes the build more verbose

Answer: A

35. How do you specify the Gradle task dependencies?

A. By adding properties to the task in the build script
B. By modifying the settings.gradle file
C. By modifying the gradle.properties file
D. By modifying the pom.xml file

Answer: A

36. What is the Gradle distribution?

A. The location of the Gradle installation files
B. The version of Gradle used by a project
C. The location of the Gradle cache
D. The location of the Gradle log files

Answer: A

37. What is the Gradle dependency resolution process?

A. The process of downloading and installing Gradle
B. The process of resolving the dependencies of a project
C. The process of configuring the build process
D. The process of executing the build tasks

Answer: B

38. How do you configure a Gradle plugin?

A. By adding properties to the plugin in the build script
B. By running the gradle configure plugin command
C. By modifying the gradle.properties file
D. By modifying the pom.xml file

Answer: A

39. What is the Gradle runtime classpath?

A. The classpath used at compile time
B. The classpath used at runtime
C. The classpath used during testing
D. The classpath used during debugging

Answer: B

40. How do you create a task dependency graph in Gradle?

A. By running the gradle showDependencies command
B. By running the gradle taskGraph command
C. By running the gradle dependencyGraph command
D. By running the gradle taskDependencyGraph command

Answer: B

41. What is the difference between the compileOnly and implementation configurations in Gradle?

A. The compileOnly configuration is only used at compile time, while the implementation configuration is used both at compile time and at runtime
B. The implementation configuration is only used at compile time, while the compileOnly configuration is used both at compile time and at runtime
C. The compileOnly and implementation configurations are identical
D. There is no such thing as the compileOnly and implementation configurations in Gradle

Answer: A

42. How do you exclude a dependency from all configurations in Gradle?

A. By adding it to the settings.gradle file
B. By adding it to the build.gradle file
C. By adding it to the gradle.properties file
D. By adding it to the pom.xml file

Answer: B

43. What is a Gradle plugin extension?

A. A module used to manage dependencies
B. A command-line tool used to run Gradle
C. A plugin used to add functionality to Gradle
D. A way to configure a plugin using Gradle syntax

Answer: D

44. What is the Gradle DSL?

A. The domain-specific language used to write Gradle build scripts
B. The domain-specific language used to write unit tests
C. A plugin used to manage dependencies
D. The domain-specific language used to write Gradle plugins

Answer: A

45. What is the Gradle composite build script?

A. The script that defines the composite build
B. The script that defines the Gradle plugins
C. A plugin used to manage dependencies
D. The script that defines the Gradle tasks

Answer: A

46. How do you execute a Gradle build in offline mode?

A. By adding the –offline flag to the gradle command
B. By adding the –offline flag to the java command
C. By adding the –offline flag to the run command
D. By adding the –offline flag to the execute command

Answer: A

47. What is the Gradle nested build?

A. A build that is contained within another build
B. A build that contains multiple subprojects
C. A build that uses Gradle as its build tool
D. A build that executes nested tasks

Answer: A

48. What is the Gradle SourceSet plugin?

A. A plugin that manages source code directories
B. A plugin that manages dependencies
C. A plugin that manages test suites
D. A plugin that configures the Gradle task display

Answer: A

49. How do you configure Gradle logging?

A. By modifying the settings.gradle file
B. By modifying the build.gradle file
C. By modifying the gradle.properties file
D. By modifying the pom.xml file

Answer: C

50. What is the Gradle test suite?

A. A suite of unit tests
B. A suite of integration tests
C. A suite of end-to-end tests
D. A suite of load tests

Answer: A

Ashwani Kumar
Latest posts by Ashwani Kumar (see all)
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x