Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


why we write public static void main (String args[])
in core java plz explain briefly??????????????????

Answers were Sorted based on User's Feedback



why we write public static void main (String args[]) in core java plz explain briefly??????????????..

Answer / nilay

because in JAVA everything is within class and should be
called with classname(static methods) or with instance of
that class. but main is the first method to be called when
no instances are in memory so that is why it is static and
is called like <classname>.main() by System class. and it
must be public because it is called from outside enviornent
of current class file. String[] is for the command line
arguments that you pass when you run your java program
by "java .classfile arg1 arg2" so all arguments are
received here and for multiple arguments it is an array of
strings. it does not return anything so it's return type is
void.

Is This Answer Correct ?    17 Yes 0 No

why we write public static void main (String args[]) in core java plz explain briefly??????????????..

Answer / sreenivas p

JVM looks for the main method(from where it starts
execution) with the same signature(public static void
main(String args[])) if it coud not find throws
NoSuchMethodError.
valid signatures are:
public static void man(String args[])
static public void main(String a[])
Invalid signatures
static void main()
public static main(String args[]) etc..[treats these
are all as general methods ]

Is This Answer Correct ?    16 Yes 3 No

why we write public static void main (String args[]) in core java plz explain briefly??????????????..

Answer / anand kumar jha

we write public because it can be called from outside the envornment and as we know that by using public keyword we will be able to access all the codes from outside,static is used because the JVM(java virtual machine which is also called as the interpreter calles the main function when there is no declaration of class instances so if we dont use static then the interprter will not check for it ,we use string and its a kind of class.It is also known as the commad line argument.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Core Java Interview Questions

Why do we use threads in java?

0 Answers  


Which is the best way of exception handling?

2 Answers   Oracle,


What is the difference between Access Modifier and Access specifier?

1 Answers  


What are the two ways you can synchronize a block of code?

5 Answers   Ericsson,


Why Do I Get A "permission Denied" Error After Downloading The .jnlp Java Launcher For The Vkvm?

0 Answers   Cisco,


What are methods of a class?

0 Answers  


1.IN CASE OF DYNAMIC METHOD DISPATCH WHY WE USE REFERENCE VARIABLE,WE CAN USE THE DIFFERENT DEFINED OBJECT DIRECTLY TO ACCESS THE DATA MEMBER AND MEMBER FUNCTION OF THAT RESPECTIVE CLASS?WHAT IS THE MAIN FUNCTION OF "REFERENCE VARIABLE" HERE?

2 Answers   TCS,


What is nullpointerexception?

0 Answers  


What is break and continue statement?

0 Answers  


Why declare Main() method as a static in java ?

0 Answers   HCL,


What is the function of compareto in java?

0 Answers  


Do you need to import math in java?

0 Answers  


Categories