Advertisements
Advertisements
प्रश्न
Answer the following in brief. Give a reason/example wherever applicable.
What is the importance of main() in a program?
कारण सांगा
Advertisements
उत्तर
- Triggers Execution: The operating system or runtime environment automatically looks for
main()to start running the application. Without it, a standalone program cannot execute. - Controls Program Flow: It acts as the central manager, invoking other functions and managing the lifecycle of the application.
- Example:
public class Car
{
//1.The engine starts here automatically
public static void main(String[]args)
{
System.out.println("Engine started.");
useBrakes();//2.
The main method activates other parts
}
public static void useBrakes()
{
System.out.println("Car stopped.");
}
}
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
