what happen if the private constructor is written in a claass

Answers were Sorted based on User's Feedback



what happen if the private constructor is written in a claass..

Answer / venkateshk

If private constructor is written in a class is preventing
to create objects for the class from outside of class.

Is This Answer Correct ?    16 Yes 0 No

what happen if the private constructor is written in a claass..

Answer / naveen.bav

It will become singleton

Is This Answer Correct ?    7 Yes 4 No

what happen if the private constructor is written in a claass..

Answer / srikanth

we cant create instance for that class

Is This Answer Correct ?    2 Yes 1 No

what happen if the private constructor is written in a claass..

Answer / 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

what happen if the private constructor is written in a claass..

Answer / gopikrishna

you can't create instance for that class

Is This Answer Correct ?    2 Yes 5 No

what happen if the private constructor is written in a claass..

Answer / ravi kumar

If we write the private constructor, it is not possible to
create the object for the class. If we want to create the
object for the class, we need to write the default
constructor, which is a public one.

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More Struts Interview Questions

What is the purpose of @conversionerrorfieldvalidator annotation?

0 Answers  


we have 7 jsp pages .At last page we have a submit button when we click it it will store all jsps data which we provide will store into database. when we starting providing data in jsp pages when we are at 3rd jsp at that time sessions timeout where the data will be store which we r provide in last two jsps?

2 Answers  


What configuration files are used in struts?

0 Answers  


Why struts 1 classes are not thread safe whereas struts 2 classes are thread safe?

0 Answers  


what are the type of forward class in Struts?

5 Answers   Wipro,






Hi All thanks in advance, iam new to j2ee currently in my project we r using struts with hibernate can i have one sample application like CRUD application with code or any tutorials liks r ebooks plz....?

1 Answers   IBM,


Are struts thread safe?

0 Answers  


What is the purpose of @key?

0 Answers  


How do you create message resource?

0 Answers  


At the point, you should go for struts framework?

0 Answers  


What is actioncontext?

0 Answers  


Who wrote struts?

0 Answers  


Categories