Jan 21, 2009

What is the effect by keeping a constructor private? (in terms of inheritance)

What is the effect by keeping a constructor private? (in terms of inheritance)
You cannot derive this class

1 comment:

  1. Anonymous00:46

    Declaring the constructor private will ensure that no one outside of the class can directly instantiate the class. In this case, the only way to create an instance of the class is to provide a static public method, as is done when using the Factory Method Pattern.

    Additionally, because the constructor is private, the class also cannot be inherited

    ReplyDelete