Java challenge question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Java challenge question

Please, explain why In Java challenge there is a question "Constructor can be private" The right answer is true. How could it be?

7th May 2019, 7:00 PM
Julia
5 Answers
+ 16
Constructor modifiers (public, protected, private), follow the same rules as normal methods, except that an 'abstract' , 'static' or 'final' constructor is not allowed.
7th May 2019, 8:42 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 10
Class will be private , so constructor will be private, In google there are lot of example here.
8th May 2019, 10:49 AM
Nasir❤
Nasir❤ - avatar
+ 7
~ swim ~ what is the main advantage of a singleton class over static classes?
7th May 2019, 11:36 PM
Sonic
Sonic - avatar
7th May 2019, 7:31 PM
Dlite
Dlite - avatar
+ 5
Constructors can be private, instatiating objects of classes with private constructors would require the use of a static method
7th May 2019, 7:11 PM
Dlite
Dlite - avatar