Single Choice Easy

QWhy is the main method declared as static in Java?

ID: #10332 Abstract class and method 171 views
Question Info
#10332Q ID
EasyDifficulty
Abstract class and methodTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A It allows the method to be called without creating an instance of the class.
  • B It ensures that the main method is executed first when the program starts.
  • C It enables the main method to access static variables and methods directly.
  • D All of the above.
Correct Answer

Explanation

The main method in Java is declared as static so that it can be called without creating an instance of the class. This is because the main method is the entry point of the program and needs to be executed first when the program starts. Additionally, the main method is declared as static so that it can access static variables and methods directly without the need to create an instance of the class.

Share This Question

Challenge a friend or share with your study group.