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
How can we handle exceptions thrown by application in Struts2?
State an example of struts configuration file as an action parameter for action servlet.
How can link tag’s action attribute be used?
What is actioncontext?
Can you explain custom tag?
What is the use of forwardaction?
What is the purpose of @results annotation?
Where can I get a copy of struts?
What is action servlet in struts?
Whats the difference between the default namespace and the root namespace?
Can we have more than one struts-config.xml file for a single struts application?
How action-mapping tag is used for request forwarding in struts configuration file?
Why use struts framework in java?
What are the core classes of struts framework? Explain
What are disadvantages of Struts?