gs gs128 Java Classes Methods - Java Constructors - Quiz No.1
gs gs128 Java Quiz
This quiz belongs to book/course code gs gs128 Java of gs organization. We have 136 quizzes available related to the book/course Java. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Java Classes Methods. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz 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 would be the behaviour if this() and super() used in a method?
Runtime error
Throws exception
compile time error
Runs successfully
Question 3: What is false about constructor?
Constructors cannot be synchronized in Java
Java does not provide default copy constructor
Constructor can have a return type
“this” and “super” can be used in a constructor
Question 4: What could be true about Class.getInstance() considering that it defines the getInstance() method?
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 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 7: What is true about protected constructor?
Protected constructor can be called directly
Protected constructor can only be called using super()
Protected constructor can be used outside package
protected constructor can be instantiated even if child is in a different package
Question 8: What is not the use of “this” keyword in Java?
Passing itself to another method
Calling another constructor in constructor chaining
Referring to the instance variable when local variable has the same name
Passing itself to method of the same class
Question 9: What would be the behaviour if one parameterized constructor is explicitly defined, but no default constructor is provided?
Compilation error
Compilation succeeds
Runtime error
Compilation succeeds but at the time of creating object using default constructor, it throws compilation error
Question 10: 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