---
title: "What if the main method is declared as private?"  
description: "What if the main method is declared as private?"  
author: "Sumit Kesarwani"  
published: 2014-03-26  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/1943/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?

When a method is declared as private, the program compiles properly but it will give runtime error Main method not public

## Answers

### Answer by Sumit Kesarwani

When a method is declared as private, the program compiles properly but it will give runtime error Main method not public


---

Original Source: https://www.mindstick.com/interview/1943/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.
