Bird
0
0

Consider this Spring Boot main class code snippet:

medium📝 component behavior Q13 of 15
Spring Boot - Fundamentals
Consider this Spring Boot main class code snippet:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MyApp {
    public static void main(String[] args) {
        SpringApplication.run(MyApp.class, args);
    }
}

What happens when you run this application?
ANothing happens because main method is missing
BThe application throws a compilation error
CThe application starts with default configuration and embedded server
DThe application runs but without any web server
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the main method

    The main method calls SpringApplication.run() with the main class, which starts the Spring Boot app.
  2. Step 2: Understand Spring Boot defaults

    Spring Boot auto-configures and starts an embedded web server by default unless configured otherwise.
  3. Final Answer:

    The application starts with default configuration and embedded server -> Option C
  4. Quick Check:

    SpringApplication.run starts app with defaults [OK]
Quick Trick: SpringApplication.run starts app with embedded server [OK]
Common Mistakes:
  • Thinking main method is missing
  • Assuming no server starts by default
  • Expecting compilation errors from correct code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes