Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

public is used so that it can be called easily from outside
the scope of function.Static is used so that it can be
easily called without using its object.

Is This Answer Correct ?    37 Yes 7 No

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

Answer / rana

As we know public means we can access the method from
anywhere.Coming to static:- main() is a static method
therefore it implies that there is no need of creating
Object for that particular class to call this method.So
that when ever u run the program the Jvm will search for
main() in the class even there r no class objects created
for this class.

Is This Answer Correct ?    20 Yes 7 No

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

Answer / ravikiran(aptech mumbai)

public means we are allowing the main method to be accessed
any where in the application.and is declared static because
jvm will look for the static one's once it completes the
loading the class.

Is This Answer Correct ?    11 Yes 5 No

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

Answer / abhijit

public means-accessable from anywhere
static means-the point ,from where compilar can start its
compilation without object.

Is This Answer Correct ?    11 Yes 10 No

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

Answer / manya

main function is used for two purposes:-1)when you have to
write a recursion code.2)to use command line arguments

Is This Answer Correct ?    1 Yes 0 No

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

Answer / balaji kumar

public - it can be access outside of the(class, package,
subclass and world).

Static- It is used to run a method without any references of
a class. Then JVM will check all the 'static' methods in
"main class" and run the main method from those.

void- main method always has no return value to outside
methods or others. so it uses void keyword.

Is This Answer Correct ?    1 Yes 0 No

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

Answer / rameshreddy.k

As we know public means we can access the method from
anywhere. in a java we want call method by using class
object. But main() is also method .that main() is there one
class but jVM execute program trough main() method with out
creating object main() method call thats way we use public
static the main function
thanks& regargs
RAMESH

Is This Answer Correct ?    4 Yes 4 No

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

Answer / bheemrao

if we don't use public in main method jvm is looked for main
method but does not found.so run time error will occurred
"main() method must be declared as public". why its static
means in java we can execute methods with object.if we use
static it will execute without object.

Is This Answer Correct ?    2 Yes 2 No

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

Answer / shekhar chauhan

public static void main()- firstly, public which r used
globly access this method in our whole progam. and static
basically used for that we can used only one main method in
whole program.we can not create object that class. so we
make static main method.

Is This Answer Correct ?    1 Yes 1 No

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

Answer / saikat chowdhury

'public' keyword is an access specifier.It means you can access anywhere of the program using this specifier.When we use in the main function it can be access outside of the(class, package,subclass.'Static' also a keyword.When we use this in the main function that means you do not need to create the object of static.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

can used Protected Class outside Function.?

0 Answers   HCL,


What is n in java?

0 Answers  


I have an HashMap object, which has with key and value pair. It has 10 keys and values in that object. Now the question is I want insert new key and value in middle or any where in that list but not at the end or at the top. Is it possible or not. If yes how can we achieve this one?

2 Answers   Huawei,


Why doesn't the java library use a randomized version of quicksort?

0 Answers  


What was java originally called?

0 Answers  


My application URL : http://localhost:8080/Application/Login.jsp. When a user enter this url in IE then, how it get Login.JSP Page exactly? what are the processes will happen from when we submit the URL to get Login.jsp?

3 Answers   IBM, TCS,


Is Java Class Threadsafe ????? How to make Java class Thread safe??

2 Answers   Cognizant,


What is difference between identifier and variable?

0 Answers  


How can we handle runtime exceptions? write one sample program? Can we write runtime exceptions beside the throws key word? if yes write sample program?

1 Answers   Huawei,


Difference between arraylist and hashset in java?

0 Answers  


Mention some interfaces implemented by linked list in java.

0 Answers  


What is not object oriented programming?

0 Answers  


Categories