1. What is Gradle primarily used for?
A. Building and automating projects
B. Managing databases
C. Running web servers
D. Graphic design
Answer: A. Building and automating projects
2. Which file is commonly used to define project dependencies in Gradle?
A. build.gradle
B. dependencies.gradle
C. project.conf
D. gradle.properties
Answer: A. build.gradle
3. In Gradle, what is a task?
A. A software development framework
B. A project configuration file
C. A unit of work that can be executed
D. A Git repository
Answer: C. A unit of work that can be executed
4. Which Gradle command is used to build a project?
A. gradle assemble
B. gradle run
C. gradle build
D. gradle compile
Answer: A. gradle assemble
5. What is the purpose of the "settings.gradle" file in a Gradle project?
A. It defines the project's main class.
B. It specifies project-wide settings.
C. It contains build scripts.
D. It stores task definitions.
Answer: B. It specifies project-wide settings.
6. What is a Gradle plugin?
A. A library for handling HTTP requests
B. A Groovy script
C. A reusable piece of build logic
D. A task definition
Answer: C. A reusable piece of build logic
7. Which build tool did Gradle replace in many projects?
A. Ant
B. Maven
C. Make
D. CMake
Answer: A. Ant
8. In a Gradle build script, which keyword is used to declare a dependency?
A. require
B. import
C. dependency
D. compile
Answer: D. compile
9. What is the purpose of the "repositories" block in a Gradle build script?
A. To define custom tasks
B. To specify where to find project source code
C. To declare project dependencies
D. To configure build flavors
Answer: B. To specify where to find project source code
10. Which Gradle command is used to list all tasks in a project?
A. gradle tasks
B. gradle list
C. gradle show
D. gradle describe
Answer: A. gradle tasks
11. What is the Gradle wrapper?
A. A tool for automatic code formatting
B. A command-line interface for Gradle
C. A shell script used to run Gradle builds
D. A Gradle plugin for generating documentation
Answer: C. A shell script used to run Gradle builds
12. What is the purpose of the "buildSrc" directory in a Gradle project?
A. It stores project source code.
B. It contains build scripts.
C. It defines custom tasks.
D. It holds shared build logic and dependencies for the project.
Answer: D. It holds shared build logic and dependencies for the project.
13. Which of the following is not a valid Gradle dependency configuration?
A. implementation
B. runtimeOnly
C. compileOnly
D. testRuntime
Answer: D. testRuntime
14. What is a Gradle task dependency?
A. A task that needs to be resolved by another task
B. A task that depends on the output of another task
C. A task that only runs in a specific environment
D. A task that has no dependencies
Answer: B. A task that depends on the output of another task
15. What is the purpose of the "gradlew" script?
A. To update Gradle to the latest version
B. To generate Gradle project documentation
C. To run Gradle builds using the Gradle Wrapper
D. To list available Gradle tasks
Answer: C. To run Gradle builds using the Gradle Wrapper
16. What does the Gradle "clean" task do?
A. Deletes the project's build output
B. Cleans the project's source code
C. Removes unused dependencies
D. Updates Gradle to the latest version
Answer: A. Deletes the project's build output
17. What is the purpose of the "init.gradle" script in Gradle?
A. To define custom tasks
B. To configure global settings for Gradle
C. To specify project dependencies
D. To declare build flavors
Answer: B. To configure global settings for Gradle
18. What is the default build file for a Gradle project?
A. build.xml
B. build.gradle
C. project.gradle
D. gradle.build
Answer: B. build.gradle
19. Which file defines the Gradle version for a project when using the Gradle Wrapper?
A. build.gradle
B. gradle.properties
C. gradle-wrapper.properties
D. settings.gradle
Answer: C. gradle-wrapper.properties
20. What is the purpose of the "doLast" and "doFirst" methods in Gradle tasks?
A. To configure project-wide settings
B. To execute code before or after the task's main action
C. To declare dependencies between tasks
D. To specify task priorities
Answer: B. To execute code before or after the task's main action
21. How can you exclude a transitive dependency in Gradle?
A. Use the "exclude" method in the "dependencies" block
B. Set the "transitive" property to false in the "dependencies" block
C. Use the "excludeTransitive" task
D. Modify the global Gradle configuration
Answer: A. Use the "exclude" method in the "dependencies" block
22. Which Gradle command is used to display project properties and their values?
A. gradle info
B. gradle properties
C. gradle project
D. gradle tasks
Answer: B. gradle properties
23. What is the purpose of the "init" task in Gradle?
A. Initializes the Gradle Wrapper
B. Initializes the project
C. Initializes the Gradle environment
D. Initializes the build.gradle file
Answer: A. Initializes the Gradle Wrapper
24. Which block in a Gradle build script is used for configuring source sets?
A. dependencies
B. plugins
C. sourceSets
D. tasks
Answer: C. sourceSets
25. In Gradle, what is a multi-project build?
A. A project with multiple build scripts
B. A project that uses multiple build tools
C. A project with multiple build tasks
D. A project that consists of multiple subprojects
Answer: D. A project that consists of multiple subprojects
26. What does the "compileJava" task do in a Java-based Gradle project?
A. Compiles Java source code
B. Compiles Gradle build scripts
C. Downloads Java libraries
D. Runs Java applications
Answer: A. Compiles Java source code
27. Which of the following plugins is commonly used for building Java projects with Gradle?
A. java-gradle-plugin
B. build-java
C. java-library
D. java
Answer: D. java
28. How do you specify the Gradle distribution URL in the Gradle Wrapper properties file?
A. In the "gradle.properties" file
B. In the "settings.gradle" file
C. In the "gradle-wrapper.properties" file
D. In the "init.gradle" script
Answer: C. In the "gradle-wrapper.properties" file
29. What is the purpose of the "buildTypes" block in an Android project's Gradle file?
A. To define custom tasks
B. To configure project-wide settings
C. To specify project dependencies
D. To define different build configurations, such as "debug" and "release"
Answer: D. To define different build configurations, such as "debug" and "release"
30. What is the recommended way to organize the project's source code in Gradle?
A. In a single directory
B. In multiple directories based on file type
C. In multiple directories based on feature or module
D. In a separate Git repository
Answer: C. In multiple directories based on feature or module
Top comments (0)