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
Are global variables initialized to zero?
Explain the available thread states in a high-level?
How does compareto work in java?
What do you mean by of string::valueof expression in java 8?
What is a boolean output?
What does index mean in java?
Can the interface be final?
What is a char in java?
What is static keyword in java?
What is a line break example?
What is exception in java?
What is the difference between break and continue statements?
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; }
What is literal example?
What is java jit compilers?