Why do we use public static with the main function in Java?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
What is method and methodology?
What is the byte range?
What is Java Package and which package is imported by default?
What are the types of strings?
What is a local class in java?
when asub class inherits a super class and overrides a public method of super class in sub class(public method in super class). why these methods needs to be public in sub class. (otherwise compile time error).
How to set the permissions to a file in java?
Why null value is used in string?
Are functions objects in java?
Is an integer an object?
why use interface? if interface declear a method implement in class. why direct implement method in class
int a=10,b=20,c=30 a= b+c;b=a+c;c=a+b; System.out.println("The value is"+a+b+c;