26-01-2010, 06:16 AM | #1 |
Member
Join Date: Dec 2009
Posts: 50
Rep Power: 15 |
main method in Java
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. |
Bookmarks |
Tags |
java, main |
|
|