Java Programming
Question 1: What is true about private constructor?
Private constructor ensures only one instance of a class exist at any point of time Private constructor ensures multiple instances of a class exist at any point of time Private constructor eases the instantiation of a class Private constructor allows creating objects in other classes
Constructors cannot be synchronized in Java Java does not provide default copy constructor Constructor can be overloaded “this” and “super” can be used in a constructor
Class.getInstance calls the constructor Class.getInstance is same as new operator Class.getInstance needs to have matching constructor Class.getInstance creates object if class does not have any constructor
Compilation error runtime error Compilation and runs successfully Only String return type is allowed
It can contain return type It can take any number of parameters It can have any non access modifiers Constructor cannot throw an exception
Compilation error Compilation succeeds Runtime error Compilation succeeds but at the time of creating object using default constructor, it throws compilation error
True False cann't say None of mentioned.
Number of score out of 7 = Score in percentage =