I have one doubt.Is it true that the main method can be marked with an access modifier other than "public"?.can we mark it with some other access modifier?I got this doubt because it is mentioned in the book "scjp exam study guide by katthy sierra and Bert Bates" that 'for the purpose of the exam assume that the main method should be marked public'. could anyone please explain it???
Well, Yes the main method you use to start an application must be public! Now having said that, there is a bug with some releases of the JDK which will allow an app to start even if the main method is declared private. Also, this is only if you wish to start the app with that, nothing prevents you from declaring the main method with another access modifier and calling it from an already running app under the constraints of the access modifier chosen. The main method is just another method. To use it to start an application the signiture MUST be: public static void main(String carl)