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

Which configuration file is used for storing jsp configuration information in struts?

539


What is dispatch action class?

605


What is the actionform?

574


How can we group related actions in one group in Struts?

555


What are the two different types of validations that the validator framework supports?

521






Define struts?

619


Which class of struts is responsible to converts data types from string and vice versa?

656


Will the struts tags support other markup languages such as wml ?

548


What kind of mvc is struts 2?

553


Describe the mvc on struts?

546


What configuration changes are required to use resource files in Struts?

566


What is the purpose of redirect result type?

568


What is java struts?

534


What is the difference between struts and spring? Explain

483


What is apache struts cve 2017 5638?

539