192). What is true about private constructor?

[A] Private constructor ensures only one instance of a class exist at any point of time
[B]Private constructor ensures multiple instances of a class exist at any point of time
[C]Private constructor eases the instantiation of a class
[D]Private constructor allows creating objects in other classes

Show Answer

193). What would be the behaviour if this() and super() used in a method?

[A]Runtime error
[B]Throws exception
[C]compile time error
[D]Runs successfully

Show Answer

194). What is false about constructor?

[A]Constructors cannot be synchronized in Java
[B] Java does not provide default copy constructor
[C]Constructor can have a return type
[D] “this” and “super” can be used in a constructor

Show Answer

195). What is true about Class.getInstance()?

[A]Class.getInstance calls the constructor
[B]Class.getInstance is same as new operator
[C]Class.getInstance needs to have matching constructor
[D]Class.getInstance creates object if class does not have any constructor

Show Answer

196). What is true about constructor?

[A] It can contain return type
[B]It can take any number of parameters
[C]It can have any non access modifiers
[D] Constructor cannot throw an exception

Show Answer

198). What is true about protected constructor?

[A]Protected constructor can be called directly
[B]Protected constructor can only be called using super()
[C] Protected constructor can be used outside package
[D]protected constructor can be instantiated even if child is in a different package

Show Answer

199). What is not the use of “this” keyword in Java?

[A]Passing itself to another method
[B]Calling another constructor in constructor chaining
[C]Referring to the instance variable when local variable has the same name
[D]Passing itself to method of the same class

Show Answer

200). What would be the behaviour if one parameterized constructor is explicitly defined?

[A] Compilation error
[B]Compilation succeeds
[C] Runtime error
[D]Compilation succeeds but at the time of creating object using default constructor, it throws compilation error

Show Answer

201). What would be behaviour if the constructor has a return type?

[A]Compilation error
[B]Runtime error
[C]Compilation and runs successfully
[D]Only String return type is allowed

Show Answer