What is the need to declare main() method as static in Java?
Answer Posted / kuldeep vishwakarma
We know very well that when we want to call any method without creating Class object in which that method is reside,this will
be perform by "static" keyword.And in java main()always call by JVM,So we can call main()without instance create with the help of jvm.Therefore we needed static with main();
INTERNALLY MAIN()CALL WITH THE HELP OF TRY-CATCH BLOCK
try{
ClassName.main();
}
catch(Exception e)
{
---------------
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How many types of jdk are there?
What is xml file in java?
Write a program for the problem: the array of inetegers indicating the marks of the students is given, U have to calculate the percentile of the students aaccording to this rule: the percentile of a student is the %of no of student having marks less then him. For eg: suppose Student Marks A 12 B 60 C 80 D 71 E 30 F 45 percentile of C = 5/5 *100 = 100 (out of 5 students 5 are having marks less then him) percentile of B = 3/5*100 = 60% (out of 5, 3 have markses less then him) percentile of A = 0/5*100 = 0%.
How do I know if I have jre or jdk?
What is connection pooling in java?
What is the use of flatmap in java 8?
What is factory pattern in java?
Can we write lambda without functional interface?
explain isalive() method under thread class?
What is the difference between collection and stream?
How can one prove that the array is not null but empty?
What is the java virtual machine (jvm)?
How do you type the lambda symbol?
When do we go for java 8 stream api? Why do we need to use java 8 stream api in our projects?
What is cdi in java?