what happen if the private constructor is written in a claass

Answer Posted / diego antonio

Yes! You can!

1.- You could have serveral constructors by requesting
different parameters set: if any of them is public, you can
use it.

2.- you could have an static method (which does not need
instance of the class) named, by example,
getNewInstance(...) which internally uses the private
constructor to instance a class (as in the factory pattern),
or as in the Singleton pattern to get the only one instance
(private and static instance).

3.- If several constructors exists, the private ones could
be called from others, but never used externally to the
class implementation.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of struts.xml in struct2?

679


What is the use of lookupdispatchaction?

565


Explain architecture of struts2?

588


What is the different actions available in struts?

546


Are interceptors thread safe?

572






How many Action classes have been used in your project? Differences between struts 1.1 and 1.3?

2536


What is token used for?

511


What is the default suffix for Struts2 action URI and how can we change it?

525


Name some useful annotations introduced in Struts2?

534


What is s token?

540


What are the steps required for setting up validator framework in struts?

567


What is the purpose of @element annotation annotation?

603


Can you explain struts.properties in struts2?

532


while working struts in intellij 7.0error unable to initialize tld location cache: zip file is closed is displayed anybdy can answer me immdialy .ungert

2056


Which servlet does the struts framework use?

522