answer of Last Post.

Last we have saw that about which are valid main method?


1. public static void Main(String args[])
2. public static int main(String args[])
3. public static void main(String[] args)
4. public final synchronized strictfp void main(String[] args)[missing static]
5. public static final synchronized strictfp void main(String[] args)
6. public static void main(String... args)

correct answer is....
First 4 is Not correct Ans. Last 2 is Correct Ans. Lets check
1 ) its Main() M is Capital letter. JVM configuration in only main which m is small letter. so 1 is not applicable.
2 ) its int return type. but main method doesn't way to any return. so 2  is not applicable.
3 ) its command line parameters is not array so we must use array String like String[]. so 3  is not applicable.
4 ) its public , final, synchoronized , strictfp, void and also main but one thing is missing is static so 4 is not applicable. because static must be were main method no way any object create . so static is missing.
5 ) its correct answer 5th because public static final synchronized strictfp void main(String[] args) so all are correct on way so this is applicable.
6 ) its correct answer in String no any array are use but were use var arg parameters. so 6 is also applicable.  

Comments