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
Explain the life cycle of a request in struct2 application?
What is the purpose of struts.xml in struct2?
Which interceptor is responsible for file upload support?
What is actionmapping?
What is the actionform?
Explain about the process of functioning of the struts program?
How do you create message resource?
Give an example of validates method used to avoid errors.
What is the purpose of '@keyproperty'?
What are the reasons for an error message not being displayed while developing struts application?
What do you mean by struts.dev mode?
Explain about struts dispatch action?
What is the purpose of @result annotation?
For a single Struts application, can we have multiple struts-config.xml files?
What are the classes used in struts?