What is the use of static keyword in "public static void
main()"

Answer Posted / rasool

The public keyword is an access specifier, which allows the
programmer to control the visibility of class members. When
a class member is preceded by public, then that member may
be accessed by code outside the class in which it is
declared.In this case, main( ) must be declared as public,
since it must be called by code outside of its class when
the program is started. The keyword static allows main( ) to
be called without having to instantiate a particular
instance of the class.

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is jagged array in java?

785


String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?

776


How do you create a first line indent?

756


List the features of java programming language.

797


Is ++ operator is thread safe in java?

730


What is java util function?

757


How do you define a method?

756


What is annotation in java?

822


What is this () in java?

781


How can you make sure that your singleton class will always return single instance in multi-threaded environment?

818


What is a singleton in genetics?

836


Which container method is used to cause a container to be laid out and redisplayed in java programming?

886


Write a java program that prints all the values given at command-line.

783


What is Mutex (Mutual Exclusion Object) ?

882


What is an immutable class?

875