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

Answer Posted / monalisa

public static void main(String[] args) means
public - is the access modifier .if we declare a method as
public means we can access the method out side of the class.
static - It is a key word.If we declare a method as static
then we can call this method with out creating any instance
of that class.Directly we can call it by "CLASSNAME.STATIC
METHOD NAME"
void - It is the return type of the method
main - It is the Method name

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is optional in java 8? What is the use of optional?advantages of java 8 optional?

505


What is the difference between ec2 and lambda?

480


Explain main thread under thread class execution?

487


Which type of stream is in java?

503


What is resultsetmetadata in java?

527






What is orm in java?

508


When do we go for java 8 stream api? Why do we need to use java 8 stream api in our projects?

568


What is the first argument of the string array in main method?

508


How to reverse the singly linked list(In Node data members are(int data,int pointerTONext))

1357


Can a dead thread be started again?

596


What is meant by framework in java?

517


What is the purpose of jdk?

450


Why dependency injection is used in java?

483


What is java api?

449


What happens when the parent process of a child process exits before the child ?

548