when everything can be done by static block then why do we
use main method?.

Answer Posted / hemanth kumar kalavagunta

Yes ... when everything can be done by static block then why
do we use main method. this is because, main method is the
only step from which compiler can enter the program to start
and this is the only way through which the data from outside
jvm can be entered into the jvm in the form of command line
arguments. using the static blocks there is no way to get
the data from the outside of the program and it is confined
to the program and program is it's world. main's world is
related both with the inside of jvm and outside of jvm.

Is This Answer Correct ?    12 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which sorting algorithm is best in java?

539


What purpose do the keywords final, finally, and finalize fulfill?

618


How variables are stored in memory?

541


What is :: operator in java 8?

560


What is boolean used for?

594






What is a top level class in java?

537


What does int argc char * argv [] mean?

522


How do you allocate memory to object?

524


Is list thread safe in java?

496


What is regex java?

566


What is replacefirst in java?

579


What sorting algorithm does javascript use?

532


What is unicode datatype?

533


What is the main function in java?

533


Can we override constructor in java?

582