Sunday, June 9, 2013

Define different main method format in Java

Do you know what do you mean of “public static void main()”?

Public

It  is “access specifier” ; so it is basically define the scope of methods, classes and interface and etc.  you know JRE (Java Run-time Environment) is the outside part of class. if we use other access specifier (private, protected) so you can’t access the that class. If you are not used any access specifier. So compiler use the default access specifier.
Static

In class there are two type members
      1-Instance member
          represent attributes and behavior of individual object. By default all the      member of class is instance member.
     2-class member
          represent attributes and behavior of whole class. Denoted  by  “static”   keyword.
So static keyword are used define the class member.
Void

Functions are always requires a return type so void is one of them to returns value implicitly. If any error occur in the program so O.S returns the value with the help of  JRE.
Main:

only method name
Are you know the given below syntax are valid or not valid  in JAVA?

Syntex-(Modifier ReturnType MethodName() )

Static public void main (String [] arg ) true
Static public void main(String[][] arg) runtime error NoSuchMethodError
Static void public main (String [][] arg) compile time error
Void static public main (String arg[]) compile time error
 public static void main (String arg) runtime error NoSuchMethodError
Public void static main ([] String arg) compile time error
Public static void main (String[] arg[]) runtime error NoSuchMethodError
Public static void main() runtime error NoSuchMethodError

                                                 Author-Ravi Kumar


No comments:

Post a Comment

Kashmir 370 and 35A : The Wound of india

क्या है जम्मू-कश्मीर में लागू धारा 370,35A पूर्ण विवरण Know about 370 act in Jammu एक बार फिर से राजनीति गलियारे में धारा 370,35A को ल...