In Java why we write public static void main(String args[])
why not main()?

Answer Posted / marrapu venkatesh.

Public: the reason for using public is to be accessed by the jvm. if u write private it should not be recognized by the jvm to execute. public methods accessed out of the class that's why we write public.
Static: the reason for static is when the program execution start main method should be invoked first. static method is called first. because we cant create object to main class to call methods. that's why we write static.
Void: In java main function does not return any value.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.

1510


How to avoid memory leak in java?

600


What is externalizable interface?

582


Is hashset ordered java?

590


What is a conditional equation?

562






What is the use of list in java?

525


Why do we declare a class static?

548


How to make a write-only class in java?

579


Given a singly linked list, determine whether it contains a loop or not without using temporary space?

583


Can we override compareto method?

507


What are peerless components in java programming?

585


What is the use of singleton class?

525


What are variable names?

530


What is the meaning of immutable regarding string?

524


Difference between a class and an object?

582