What happens when a main method is declared as private?
Answer Posted / pawan
vani, varsha is correct , the 'private main method' is as
good as any member method your class can have (note that
main is not a key word in java) , it can be only used inside
the class in which it is defined.
It is clearly mentioned in the specifications that the
executing class should contain a 'public static void method'
as a point of execution otherwise execution will fail
complaining ABOUT THE METHOD WHICH I MENTIONED ABOVE.
| Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
Can an anonymous class be declared as implementing an interface and extending a class in java programming?
What is the method in java?
What is map in java?
what invokes a threads run() method? : Java thread
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread
Why there are some null interface in java? What does it mean?
Define max and min heap, also the search time of heap.
Name few "optional" classes introduced with java 8 ?
Does constructor be static?
What is the syntax and characteristics of a lambda expression? Explain
If you are given the name of the function at run time how will you invoke the function?
What is the difference between member variables initialization and assignment in a constructor?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
Is java still relevant?
Why does java not support pointers?