Bird
0
0

Identify the error in this Spring Boot main class:

medium📝 Debug Q6 of 15
Spring Boot - Fundamentals
Identify the error in this Spring Boot main class:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootApplication;

@SpringBootApplication
public class MyApp {
  public static void main(String[] args) {
    SpringApplication.run(MyApp);
  }
}
AClass name does not match file name
BWrong annotation used for main class
CMissing '.class' and second argument 'args' in SpringApplication.run
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check SpringApplication.run method signature

    It requires a class literal (MyApp.class) as first argument and String[] args (varargs).
  2. Step 2: Identify missing argument

    The code calls run(MyApp), missing .class on the class reference and args, causing a compile error.
  3. Final Answer:

    Missing '.class' and second argument 'args' in SpringApplication.run -> Option C
  4. Quick Check:

    run() needs class and args [OK]
Quick Trick: SpringApplication.run needs both class and args [OK]
Common Mistakes:
  • Omitting args parameter in run method
  • Confusing annotation names
  • Ignoring method signature requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes