What happens when a main method is declared as private?
Answer Posted / chinmay
If main method declared as private then at compilation no problem but at run time it shows an error that main method should be public...
because we access the main() method out side from class if it is private then it cannot be accessible...
that's why we have to write public in main method signature...
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How to create a custom exception?
What is an example of a constant variable?
What modifiers may be used with an inner class that is a member of an outer class in java programming?
What is var keyword ?
What is lazy initialization in java?
What is the significance of java packages?
Why are arrays useful in java?
Can a constructor call the constructor of parent class?
What does indexof mean?
What is the difference between compile-time polymorphism and runtime polymorphism?
Can an interface have a class?
Why parameters should be passed by reference?
What is the purpose of return statement?
Explain notifyall() method of object class ?
How do you define a method?