---
title: "Where and how can you use a private constructor in java?"  
description: "Where and how can you use a private constructor in java?"  
author: "Sumit Kesarwani"  
published: 2014-04-10  
updated: 2020-09-15  
canonical: https://www.mindstick.com/interview/1949/where-and-how-can-you-use-a-private-constructor-in-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Where and how can you use a private constructor in java?

Private constructor is used if you do not want other classes to instantiate the object and to prevent sub-classing. The instantiate is done by a public static method (i.e. a static factory method) within the same class.

## Answers

### Answer by Sumit Kesarwani

Private constructor is used if you do not want other classes to instantiate the object and to prevent sub-classing. The instantiate is done by a public static method (i.e. a static factory method) within the same class.


---

Original Source: https://www.mindstick.com/interview/1949/where-and-how-can-you-use-a-private-constructor-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
