---
title: "Default Constructor"  
description: "Default Constructor"  
author: "Anonymous User"  
published: 2018-06-20  
updated: 2018-06-20  
canonical: https://www.mindstick.com/forum/34531/default-constructor  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Default Constructor

What Is A [Default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources) Constructor ?

## Replies

### Reply by Prakash nidhi Verma

Default Constructor :

If you are going to instantiate an array of objects of the class, the class must have a default constructor. If no user-defined constructor exists for a class A and one is needed, the compiler implicitly declares a default parameter less constructor A::A() .

Syntax:

```
class X { public:
  X();                       // Default constructor with no arguments
  X(int = 0);                // Default constructor with one default argument
  X(int, int , int = 0);     // Constructor
};
```

Ex:

```
// Main.java class Test {
   int i;
   Test t;
   boolean b;
   byte bt;
   float ft;
}
public class Main {
    public static void main(String args[]) {
      Test t = new Test(); // default constructor is called.
      System.out.println(t.i);
      System.out.println(t.t);
      System.out.println(t.b);
      System.out.println(t.bt);
      System.out.println(t.ft);
    }
}
```


---

Original Source: https://www.mindstick.com/forum/34531/default-constructor

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
