The constructor has the same name as the class name. It is used for initializing variables of the class. It is called whenever an object of the class is created. It does not have a return type, not even void.
Why do we use constructor in selenium page object model?
Note: A constructor has to be created in each of the class in the Page Layer, in order to get the driver instance from the Main class in Test Layer and also to initialize WebElements(Page Objects) declared in the page class using PageFactory.
Do we use any constructor in selenium WebDriver?
It only has a constructor which takes a WebDriver object and passes it on to its superclass constructor. Again, note that none of the page objects nor the BasePage initialize the WebDriver Objects.