What is the need to declare main() method as static in Java?

Answer Posted / dadhich

main method is declared as static because we cannot call the method without creating the object of the class.When we declare class and in which if we define main method then it is must to use the static keyword.static keyword helps to execute the main method without instantiating the class.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is transient in java?

668


In java what is the difference between sleep() and wait() .

688


Topic- looping,function overloading,nesting ,polymorphism. Aim - to write a function with a name buzz-buds,that will check whether the given numbers are buddies or not on the basis of no. of parameters passed during function calling.

1820


What is dto in java?

699


Explain different way of using thread?

760


What is ui framework in java?

651


Why we use beans in java?

706


What is meant by framework in java?

713


Is jvm a compiler or an interpreter?

725


what is reflection api? How are they implemented?

745


What is the use of jprofiler?

655


What is setstring method in java?

709


What are the benefits of a jar file?

774


What gives java it’s “write once and run anywhere” nature?

779


What is the difference between Logical Parallelism and Physical Parallelism?

3173