---
title: "What if the main method is declared as private?"  
description: "What if the main method is declared as private?"  
author: "Chris Anderson"  
published: 2012-06-13  
updated: 2020-09-19  
canonical: https://www.mindstick.com/interview/1474/what-if-the-main-method-is-declared-as-private  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What if the main method is declared as private?

The program compiles properly but at runtime it will give “Main method not public.” message.

## Answers

### Answer by Chris Anderson

The program compiles properly but at runtime it will give “Main method not public.” message.


---

Original Source: https://www.mindstick.com/interview/1474/what-if-the-main-method-is-declared-as-private

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
