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 the meaning of java.lang and java.util

6 Answers  


What is a pattern what is an anti pattern?

0 Answers  


what is polymorphism with example?types of polymorphism?

15 Answers   HP, Sigma Solve,


Explain different ways of creating a thread?

0 Answers  


transaction attributes ?

2 Answers  






What is a dynamic array java?

0 Answers  


What is the difference between a switch statement and an if statement?

0 Answers  


what is thread in Java ?

0 Answers  


How many types of threads are there in java?

0 Answers  


Is 0 an irrational number?

0 Answers  


how can we synchronize Hash map?

3 Answers   CTS,


Name and explain the types of ways which are used to pass arguments in any function in java.

0 Answers  


Categories