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

Which of the following is not an isolation level in the JDBC

1608


What are the different ways of creating thread?

568


What are the steps involved to write rmi based programs?

561


what are the high-level thread states? : Java thread

556


What is widening and narrowing in java? Discuss with an example.

554






How many types of voids are there?

533


Which list is sorted in java?

580


What is unsigned char?

612


What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. Import java.net.* Versus import java.net.socket)?

588


Can a static class have a constructor?

515


Is list thread safe in java?

487


What is a method in programming?

630


What is a ternary operator in java?

530


What is default constructors?

537


What sorting algorithm does javascript use?

526