Need to use public,static keywords in main function?

Answers were Sorted based on User's Feedback



Need to use public,static keywords in main function? ..

Answer / anjani kumar jha

public is used because from anywhere u r able to call ur
main method

static-static is the entry point of main function which is
executing by jvm(at run time) in other word signature of
the main function.

Is This Answer Correct ?    12 Yes 1 No

Need to use public,static keywords in main function? ..

Answer / psreddy

public access modifier we declared then that class visible
to every where and access to any where
bcoz if we write any number business logic classes but
we have to write only one execution logic class for all
these business logic classes
that is why always execution logic class as public
and also there is need of writing static key word
bcoz the execution logic executes only once
other wise we will get runtime exeption

Is This Answer Correct ?    5 Yes 1 No

Need to use public,static keywords in main function? ..

Answer / aravinda reddy

1) Public access modifier specifies class declared can be
accesses from anywhere

2) where as static refers with out creating instance of the
class JVM should access the main class while executing.

3) void specified main function should not return any value

Is This Answer Correct ?    1 Yes 0 No

Need to use public,static keywords in main function? ..

Answer / suresh

Main method is called by jvm...
jvm is out side the class
so main method must be pulic
then only jvm can access.

No instance of the class is needed to
execute the static method.

Is This Answer Correct ?    1 Yes 0 No

Need to use public,static keywords in main function? ..

Answer / sreedhar

yes,need two thing, javac execution start with main
method,that method declars the private,protected not access
the out side class.

Staic block is execute the first part of the progream ,u
need to mention the Staic on thet main method.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What does file separator do in java?

0 Answers  


Is char a method in java?

0 Answers  


What is the difference between synchronized and synchronized block?

0 Answers  


What are keyboard events?

0 Answers  


what are the oops concept in java explain with real time examples

24 Answers   Accenture, Bosch, Consummate Technologies, CTS, Current Technologies, iNautix, Infosys, Kekran Mekran, QA InfoTech, RTRT, SofTech, Tech Mahindra, Thorogood, Timios, Wipro,


what is difference between method overloading & method overridding with example?

4 Answers   IBM,


I/O blocking means?

1 Answers  


What flag up means?

0 Answers  


What is the Dictionary class?

1 Answers  


when to use abstract class and when to use interface?

16 Answers   Exterro, iGate, IonIdea,


How many bytes is 255 characters?

0 Answers  


Is void a wrapper class?

0 Answers  


Categories