---
title: "What is a rules for defining a constructor"  
description: "What is a rules for defining a constructor"  
author: "Samuel Fernandes"  
published: 2016-11-07  
updated: 2020-09-16  
canonical: https://www.mindstick.com/interview/23095/what-is-a-rules-for-defining-a-constructor  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What is a rules for defining a constructor

The rules for constructor creation can be summarized as follows:\
•A constructor must have the same name as the class name.•A constructor does not return anything, not even a void type.•A constructor may take zero or more arguments.•By default, the compiler provides a no-argument constructor.•If you provide any constructor—either a no-argument constructor or a constructor with arguments—the compiler does not provide a default constructor.\
Thanks

## Answers

### Answer by Samuel Fernandes

The rules for constructor creation can be summarized as follows:\
•A constructor must have the same name as the class name.•A constructor does not return anything, not even a void type.•A constructor may take zero or more arguments.•By default, the compiler provides a no-argument constructor.•If you provide any constructor—either a no-argument constructor or a constructor with arguments—the compiler does not provide a default constructor.\
Thanks


---

Original Source: https://www.mindstick.com/interview/23095/what-is-a-rules-for-defining-a-constructor

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
