My Hindi Forum

My Hindi Forum (http://myhindiforum.com/index.php)
-   Tech Talks (http://myhindiforum.com/forumdisplay.php?f=20)
-   -   main method in Java (http://myhindiforum.com/showthread.php?t=251)

javaguru 26-01-2010 06:16 AM

main method in Java
 
Q - Briefly explain the reason that the main method in a Java application is declared public.

A - The keyword public indicates that the method can be called by any object.

Q - Explain the reason that the main method in a Java application must be declared static.

A - The keyword static indicates that the method is a class method which can be called without the requirement to instantiate an object of the class. This is used by the Java interpreter to launch the program by invoking the main method of the class identified in the command to start the program.

Q - Describe the purpose of the keyword void when used as the return type for the main method.

A - The void keyword when used as the return type for any Java methods indicates that the method does not return anything.

Q - What is the use of args[]?

A - The formal parameter args is an array of type String, which contains arguments entered at the command line. Note that the args parameter must be specified whether or not the user is required to enter a command-line argument and whether or not the code in the program actually makes use of the argument.


All times are GMT +5. The time now is 06:48 AM.

Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
MyHindiForum.com is not responsible for the views and opinion of the posters. The posters and only posters shall be liable for any copyright infringement.