In Java why we write public static void main(String args[])
why not main()?

Answer Posted / rahul

The public keyword is an access specifier, which allows the
programmer to control the visibility of class members. When
a class member is preceded by public, then that member may
be accessed by code outside the class in which it is
declared.In this case, main( ) must be declared as public,
since it must be called by code outside of its class when
the program is started.

The keyword static allows main( ) to be called without
having to instantiate a particular instance of the class.
This is necessary since main( ) is called by the Java
interpreter before any objects are made.

The keyword void simply tells the compiler that main( )
does not return a value. As you will see, methods may also
return values.
about strings[] It takes no of arguements & stored in an
array ,input is of integer type it is taken as string. so
main takes arguments of type string.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are global variables initialized to zero?

517


Explain the available thread states in a high-level?

535


How does compareto work in java?

586


What do you mean by of string::valueof expression in java 8?

551


What is a boolean output?

532






What does index mean in java?

544


Can the interface be final?

584


What is a char in java?

541


What is static keyword in java?

558


What is a line break example?

583


What is exception in java?

573


What is the difference between break and continue statements?

555


public class Test { public static void main(String[] args) { int countA = 0; int countB = 0; int countC = 0; int countD = 0; int countE = 0; int countF = 0; int countG = 0; int countH = 0; int countI = 0; int countJ = 0; int countK = 0; int countL = 0; int countM = 0; int countN = 0; int countO = 0; int countP = 0; int countQ = 0; int countR = 0; int countS = 0; int countT = 0; int countU = 0; int countV = 0; int countW = 0; int countX = 0; int countY = 0; int countZ = 0; } } Can anybody tell me any alternate solution(like loop or something) to automate this initialization process. Ex:- for(char chr='A';chr<='Z'; chr++) { (int) String "count"+chr = 0; }

1854


What is literal example?

566


What is java jit compilers?

562