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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we extend immutable class?

735


State the main difference between c++ and java?

770


Why is it important to initialize a variable?

721


How many types of variables are there?

873


What happens to the Exception object after handling an exception?

2055


what is mutual exclusion? : Java thread

755


How many types of parsers are there?

766


What is constructor chaining in java?

803


What is keyword auto for?

860


Is arraylist dynamic in java?

704


What is square root in java?

771


What is sorting algorithm in java?

762


Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example

2317


Why can't we use static class instead of singleton?

690


What is difference between static class and normal class?

726