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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / guest

the main block is declared as static sothat the java
interpreter could use it without instantiating it,but if we
declare everything as static there is no meaning of a class
and specifying instance variables and methods belong to
that specific class only.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More Core Java Interview Questions

What is sorting in java?

0 Answers  


Can I overload to string method

0 Answers   UHG,


What are the important features of Java 10 release?

0 Answers  


What is a superclass?

0 Answers  


How can you add and remove nodes in jtree?

0 Answers  






What do you understand by final value?

0 Answers  


What is the difference between Access Modifier and Access specifier?

1 Answers  


Can a class have more than one object?

0 Answers  


Why Static variable required in java?For ex,class A { static int a; int b; } Why static is required?

5 Answers   Ericsson,


What is the covariant return type?

0 Answers  


What is autoboxing and unboxing?

0 Answers  


What happens if an exception is not handled in a program?

0 Answers  


Categories