What is the use of Private Constructor in a Class?
Daljeet Singh
1.) To initialize the private variables in a class. 2.) Also to ensure or prevent user from creating instance of a class. Similar to singleton pattern in which - class object will be created internally and passed in through a Public static property etc. So developer will not be able to create instance by calling default constructor.
Its use whe we are using singleton pattern in application development. Its bind to developer to can not create another instance if already one instance exist and its also restrict developer to create default instance of class.