Question :Why do we require public static void main(String args[]) method in Java
programme? (CoreJava)
Answer :Following are few reasons why there is public static void main(String
args[])
a. public: The method can be accessed outside the class / package
b. static: You need not have an instance of the class to access the method
c. void: Your application need not return a value, as the JVM launcher
would return the value when it exits
d. main(): This is the entry point for the application
If the main() was not static, you would require an instance of the class in
order to execute the method.
If this is the case, what would create the instance of the class? What if
your class did not have a public constructor?
java Test
would get converted to Test.main() there by invoking the main()
www.interviewhelper.org is a hope for all the Job seekers. Users can find unlimited here. These range from technical to HR, from functional to behavioral. www.interviewhelper.org contains in the fields like Ajax,VB,Networking,Sharepoint,JEE,Perl,Javascript,Bioinformatics,Classic ASP,Unix,Linux,Accounting,Oracle DBA,Microprocessor,Bluetooth,jms,jme,.net framework,ABAP,ASP,ASP.net,Basic .net Framework,Interview Questions,C language,C++,database,Oracle,Java,PHP,LAMP,SAP etc.
Thursday, March 12, 2009
Why do we require public static void main(String args[]) method in Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment