Constructors:

Constructors are special methods within a class that are used to initialize the state of an object when it is created. Constructors have the same name as the name of the class and they do not have a return type, not even void.

Default Constructor:

constructor.java
public class MyClass {
    // Default constructor is present
}


Parameterized Constructor:

You can define constructors that accept parameters to initialize the object with specific values.

constructor.java
public class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
}

Constructor Overloading:

You can define multiple constructors with different parameter lists within the same class. This is called constructor overloading.

constructor.java
public class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Person(String name) {
        this.name = name;
        this.age = 0; // Default age
    }
}

`this` keyword:

`this` is actually a pointer which refers to the same class in which it is present.

For example, we are present in a class named "Person". It has an attribute "age". Now whenever we write this.age, we are specifically targetting to the age variable of the Person class.

Similarly, if we are present in Employee class and it has a variable named "salary". So, whenever we write this.salary, we are specifically targetting to the salary variable of the Employee class.