a) Compilation error b) Runtime error c) Compilation and runs successfully d) Only String return type is allowed Answer: ...
View QuestionWhat 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 ...
View QuestionWhat 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 ...
View QuestionWhat is true about protected constructor?
a) Protected constructor can be called directly b) Protected constructor can only be called using super() c) ...
View QuestionAbstract class cannot have a constructor.
a) True b) False Answer: b Explanation: No instance can be created of abstract ...
View QuestionWhat is true about constructor?
a) It can contain return type b) It can take any number of parameters c) It can ...
View QuestionWhat 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
View QuestionWhat is false about constructor?
a) Constructors cannot be synchronized in Java b) Java does not provide default copy constructor c) Constructor can have ...
View QuestionWhat 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 Answer: c Explanation: this() and super() ...
View QuestionWhat is true about private constructor?
a) Private constructor ensures only one instance of a class exist at any point of time b) Private ...
View Question