Constructor Program in Java
In Java, a constructor is a piece of code that is used to create an object. A constructor is called implicitly when an object is created in Java using the new keyword. A constructor looks like an instance method. However, a constructor and an instance method are two different things. A Java constructor is often regarded as a special type of method in Java. Constructor program in Java tells about how to use constructors in a program. Constructors always have the same name as the name of the class. Whenever a new object is created in Java, the constructor initializes that object. A class may or may not contain more than one constructor. The following rules must be followed to define a constructor in Java
1) Constructor name and class name should always match.
2) No return type should be given to a Java constructor.
3) Keywords like synchronized, static, native, final, and abstract should not be used with a Java constructor. However, access specifiers like private, protected, public can be used with a constructor.
For more details refer the link https://www.tutorialandexample.com/function-pointer-in-cpp/