हिंदी

Answer the following in brief. Give a reason/example wherever applicable. What is the importance of main() in a program?

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: User-Defined Methods - Exercises [पृष्ठ ९१]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 3 User-Defined Methods
Exercises | Q 5. (i) | पृष्ठ ९१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×