What if the main method is declared as private core java interview questions and answers

1,384 views · Published 15 September 2012 · 2:24 · Indexed 5 October 2026

Channel: Interview DOT · 2012 · Science & Technology

Watch on YouTube

Click here - https://www.youtube.com/channel/UCd0U_xlQxdZynq09knDszXA?sub_confirmation=1 to get notifications. http://www.interviewdot.com

Welcome to www.InterviewDot.com     How to prepare for Java interview Questions :    

Core Java Interview Questions and Answers :


What if the main() method is declared as private?

The program compiles properly but at runtime it will give "main() method not public." message.

Public class mainDemo {
 Private static void main(){
  /// will it compile ? -- yes it compiles & but you cant make it run ??
 }
}



For more Java Interview questions and answers  - logon to www.InterviewDot.com - India's Top Interview Guide.

More from this channel