0
0
Spring Bootframework~20 mins

Running a Spring Boot application in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Spring Boot Starter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when you run this Spring Boot main class?
Consider this Spring Boot application main class. What will be the output in the console when you run it?
Spring Boot
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
        System.out.println("Application started");
    }
}
AThe console shows Spring Boot startup logs followed by 'Application started'.
BOnly 'Application started' is printed, no Spring Boot logs appear.
CThe application starts but does not print anything to the console.
DThe application fails to start due to missing @EnableAutoConfiguration annotation.
Attempts:
2 left
💡 Hint
SpringApplication.run starts the Spring Boot context and logs startup info before the next line runs.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in this Spring Boot main class
Which option correctly fixes the syntax error in this Spring Boot main class?
Spring Boot
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class args);
    }
}
AAdd a comma between DemoApplication.class and args: SpringApplication.run(DemoApplication.class, args);
BRemove args completely: SpringApplication.run(DemoApplication.class);
CReplace args with new String[]{}: SpringApplication.run(DemoApplication.class new String[]{});
DAdd a semicolon after DemoApplication.class: SpringApplication.run(DemoApplication.class; args);
Attempts:
2 left
💡 Hint
Check the method call syntax and parameter separation.
state_output
advanced
2:00remaining
What is the value of 'running' after this Spring Boot application starts?
Given this code snippet, what will be the value of the 'running' variable after the application starts?
Spring Boot
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class, args);
        boolean running = context.isRunning();
        System.out.println(running);
    }
}
Afalse
Btrue
Cnull
DThe code throws an exception
Attempts:
2 left
💡 Hint
Check what isRunning() returns after SpringApplication.run completes.
🔧 Debug
advanced
2:00remaining
Why does this Spring Boot application fail to start?
This Spring Boot application fails with an error. What is the cause?
Spring Boot
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run();
    }
}
AThe main method must return a value; void is invalid.
BThe @SpringBootApplication annotation is missing required parameters.
CSpringApplication.run() requires at least one argument; missing arguments cause a compile error.
DThe class must extend SpringBootServletInitializer to run.
Attempts:
2 left
💡 Hint
Check the method signature of SpringApplication.run.
🧠 Conceptual
expert
3:00remaining
What is the role of the @SpringBootApplication annotation when running a Spring Boot app?
Which statement best describes what @SpringBootApplication does when you run a Spring Boot application?
A@SpringBootApplication only marks the class as a REST controller for handling HTTP requests.
B@SpringBootApplication is optional and has no effect on application startup.
C@SpringBootApplication disables auto-configuration and requires manual bean registration.
D@SpringBootApplication combines @Configuration, @EnableAutoConfiguration, and @ComponentScan to configure and start the app automatically.
Attempts:
2 left
💡 Hint
Think about what annotations @SpringBootApplication groups together.