Why do we use public static with the main function in Java?

Answers were Sorted based on User's Feedback



Why do we use public static with the main function in Java?..

Answer / abhi

why all these guys used to say "no need to create objects for a static class" tell what advantages u wil b geting without creating an object.

Is This Answer Correct ?    0 Yes 0 No

Why do we use public static with the main function in Java?..

Answer / ankit

public is written so that it can be called from outside and
static is written because main is called before the creation
of any object and for static methods object is not required.

Is This Answer Correct ?    1 Yes 2 No

Why do we use public static with the main function in Java?..

Answer / deepak divvela

In the main function generally we are using
public static void main(String args[])
that means public is used for call method without being the
member of the class.
and static is used for to call method directly with no need
of the object creation.

Is This Answer Correct ?    3 Yes 7 No

Post New Answer

More Core Java Interview Questions

What is the purpose of main function in java?

0 Answers  


What is are packages?

0 Answers  


Is java an ide?

0 Answers  


What is the root class for all Java classes?

8 Answers   IBM, Infosys,


In which JDK version event-delegation model is introduced?

1 Answers  






why would you use a synchronized block vs. Synchronized method? : Java thread

0 Answers  


Can you create an object of an abstract class?

0 Answers  


Can a class with private constructor be extended?

0 Answers  


Can we use synchronized block for primitives?

0 Answers  


What is a bufferedreader?

0 Answers  


How would you format a date in java? I.e. In the ddmmyyy format?

0 Answers  


Explain the difference between map and flatmap stream operation?

0 Answers  


Categories