Bird
Raised Fist0
Spring Bootframework~20 mins

Project structure walkthrough in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Spring Boot Structure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the purpose of the 'src/main/resources' folder in a Spring Boot project?
In a typical Spring Boot project, what kind of files do you place inside the 'src/main/resources' folder?
AJava source code files that contain the main application logic.
BTest source code files for unit and integration tests.
CConfiguration files, static assets, and templates used by the application.
DCompiled class files generated after building the project.
Attempts:
2 left
💡 Hint

Think about where you keep files like application.properties or HTML templates.

❓ component_behavior
intermediate
2:00remaining
What happens if you place a Java class outside 'src/main/java' in a Spring Boot project?
Consider a Java class placed in 'src/test/java' instead of 'src/main/java'. What is the effect on the Spring Boot application?
AThe class will only be compiled and used during testing, not in the main application runtime.
BThe class will be included in the main application build and run normally.
CThe class will cause a build failure due to incorrect folder placement.
DThe class will be ignored completely and not compiled or used anywhere.
Attempts:
2 left
💡 Hint

Think about the difference between main and test source folders.

📝 Syntax
advanced
2:00remaining
Which folder should you place your Spring Boot controller classes in for proper component scanning?
Given a Spring Boot project with base package 'com.example.app', where should controller classes be placed to be detected automatically?
Acom.example.app.services inside 'src/main/resources'
Bcom.example.controllers outside the base package
Ccom.example.app.controllers inside 'src/test/java'
Dcom.example.app.controllers inside 'src/main/java'
Attempts:
2 left
💡 Hint

Controllers must be inside the base package or its subpackages.

🔧 Debug
advanced
2:00remaining
Why does Spring Boot fail to find your application.properties file?
You placed your application.properties file in 'src/main/java' instead of 'src/main/resources'. What will happen when you run the app?
AThe application will crash with a FileNotFoundException.
BSpring Boot will fail to load the properties file because it only looks in 'src/main/resources'.
CThe application.properties file will be ignored but no error will occur.
DSpring Boot will load the properties file without any issues.
Attempts:
2 left
💡 Hint

Where does Spring Boot expect configuration files to be?

❓ lifecycle
expert
2:00remaining
What is the role of the 'META-INF' folder inside 'src/main/resources' in a Spring Boot project?
You find a 'META-INF' folder inside 'src/main/resources'. What is its typical purpose in a Spring Boot application?
AIt holds metadata files like 'MANIFEST.MF' that describe the packaged jar.
BIt stores static web assets like CSS and JavaScript files.
CIt contains compiled Java bytecode for the application.
DIt contains test reports generated after running tests.
Attempts:
2 left
💡 Hint

Think about what metadata about the jar or application might be stored.

Practice

(1/5)
1. In a typical Spring Boot project, where should you place your main application Java files?
easy
A. src/resources/java
B. src/main/resources
C. src/test/java
D. src/main/java

Solution

  1. Step 1: Understand Spring Boot folder roles

    The src/main/java folder is for main Java source code including the application entry point.
  2. Step 2: Identify correct folder for main Java files

    Main application files should not be in resources or test folders, so src/main/java is correct.
  3. Final Answer:

    src/main/java -> Option D
  4. Quick Check:

    Main Java code = src/main/java [OK]
Hint: Main Java code always goes under src/main/java [OK]
Common Mistakes:
  • Confusing resources folder with Java source folder
  • Placing main code in test folder
  • Using incorrect folder names like src/resources/java
2. Which file is commonly used to manage dependencies and build steps in a Spring Boot Maven project?
easy
A. pom.xml
B. application.properties
C. build.gradle
D. settings.xml

Solution

  1. Step 1: Identify build tool for Maven projects

    Maven uses pom.xml to manage dependencies and build configuration.
  2. Step 2: Differentiate from Gradle and config files

    build.gradle is for Gradle, application.properties is for app config, and settings.xml is not for dependencies.
  3. Final Answer:

    pom.xml -> Option A
  4. Quick Check:

    Maven build file = pom.xml [OK]
Hint: Maven uses pom.xml; Gradle uses build.gradle [OK]
Common Mistakes:
  • Confusing application.properties with build files
  • Mixing Gradle and Maven build files
  • Thinking settings.xml manages dependencies
3. Given this Spring Boot project structure snippet, where will the test Java files be located?
src/
  main/
    java/
    resources/
  test/
    java/
    resources/
medium
A. src/main/resources
B. src/test/java
C. src/main/java
D. src/test/resources

Solution

  1. Step 1: Understand test folder purpose

    The src/test/java folder is for Java test source files.
  2. Step 2: Identify test Java files location

    Test Java files go under src/test/java, not in main or resources folders.
  3. Final Answer:

    src/test/java -> Option B
  4. Quick Check:

    Test Java code = src/test/java [OK]
Hint: Test Java files go in src/test/java folder [OK]
Common Mistakes:
  • Putting test Java files in src/main/java
  • Confusing test resources with test Java code
  • Using src/main/resources for tests
4. You accidentally placed your application.properties file inside src/main/java. What problem will this cause?
medium
A. The application will fail to start due to missing config
B. The build will fail with a syntax error
C. The properties file will be ignored and default config used
D. The application.properties will be loaded correctly anyway

Solution

  1. Step 1: Know where Spring Boot loads config files

    Spring Boot loads application.properties from src/main/resources or classpath root.
  2. Step 2: Effect of wrong file location

    If placed in src/main/java, it won't be found and ignored, so defaults apply.
  3. Final Answer:

    The properties file will be ignored and default config used -> Option C
  4. Quick Check:

    Config files must be in resources, else ignored [OK]
Hint: Config files must be in resources folder to load [OK]
Common Mistakes:
  • Assuming app fails to start immediately
  • Thinking build fails due to config file location
  • Believing misplaced properties still load
5. You want to add a new configuration file for your Spring Boot app that should be packaged inside the jar and accessible at runtime. Where should you place this file?
hard
A. src/main/resources/config
B. src/main/java/config
C. src/test/resources/config
D. src/main/resources/static

Solution

  1. Step 1: Understand resource packaging in Spring Boot

    Files in src/main/resources are packaged inside the jar and available at runtime.
  2. Step 2: Choose correct folder for config files

    Config files should be under src/main/resources/config to be included and organized.
  3. Final Answer:

    src/main/resources/config -> Option A
  4. Quick Check:

    Runtime config files go in src/main/resources [OK]
Hint: Put runtime config files in src/main/resources folder [OK]
Common Mistakes:
  • Placing config files in src/main/java which is for code
  • Using test resources folder which is not packaged
  • Putting config in static folder meant for web assets
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard