My Hindi Forum

Go Back   My Hindi Forum > Miscellaneous > Tech Talks
Home Rules Facebook Register FAQ Community

Reply
 
Thread Tools Display Modes
Old 26-01-2010, 06:16 AM   #1
javaguru
Member
 
javaguru's Avatar
 
Join Date: Dec 2009
Posts: 50
Rep Power: 15
javaguru is on a distinguished road
Default 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.
javaguru is offline   Reply With Quote
Reply

Bookmarks

Tags
java, main


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT +5. The time now is 02:05 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.