Constructors and Constructor Overloading

PRE TEST :


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


Question 2:
What is false about constructor?
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


Question 3:
What is true about Class.getInstance()?
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


Question 4:
What would be behaviour if the constructor has a return type?
Compilation error
runtime error
Compilation and runs successfully
Only String return type is allowed


Question 5:
What is true about constructor?
It can contain return type
It can take any number of parameters
It can have any non access modifiers
Constructor cannot throw an exception


Question 6:
What would be the behaviour if one parameterized constructor is explicitly defined?
Compilation error
Compilation succeeds
Runtime error
Compilation succeeds but at the time of creating object using default constructor, it throws compilation error


Question 7:
Abstract class cannot have a constructor.
True
False
cann't say
None of mentioned.


Number of score out of 7 = Score in percentage =