Java Constructors MCQ Questions and Answers

1. What is a constructor in Java?

a) A method that returns a value
b) A special method used to initialize objects
c) A static method called at class loading
d) A final method in a class

2. How is a constructor in Java identified?

a) It has the same name as the class and a return type
b) It has a different name from the class and no return type
c) It has the same name as the class and no return type
d) It is marked with the 'constructor' keyword

3. Can a Java class have more than one constructor?

a) Yes, it's called constructor overloading
b) No, it can only have one constructor
c) Yes, but they must have the same parameters
d) No, constructors are static and unique

4. What happens if no constructor is defined in a Java class?

a) The class cannot create objects
b) A default constructor is provided by the Java compiler
c) An error occurs during compilation
d) The class uses the constructor of its superclass

5. What is a default constructor in Java?

a) A constructor provided by the user without parameters
b) A constructor that sets all object properties to default values
c) A constructor automatically provided by Java with no parameters
d) The first constructor in a class

6. What is the purpose of a parameterized constructor in Java?

a) To initialize objects with different methods
b) To initialize objects with specific values
c) To define static initializations
d) To overload the main method

7. Can a constructor be private in Java?

a) Yes, for singleton class pattern
b) No, constructors must always be public
c) Yes, but only in abstract classes
d) No, constructors cannot have access modifiers

8. How do you call a superclass constructor in Java?

a) super()
b) this()
c) superClass()
d) extend()

9. What is constructor chaining in Java?

a) Calling one constructor from another within the same class
b) Creating multiple constructors with the same name
c) Connecting two different classes through their constructors
d) A sequence of constructors calling each other in different classes

10. Which of these is not a feature of constructors in Java?

a) They can return values
b) They have the same name as the class
c) They do not have a return type
d) They are used to initialize objects

11. What is the use of the 'this' keyword in constructors?

a) To call another constructor in the same class
b) To refer to the current class instance
c) To call a method in the same class
d) Both a and b

12. What differentiates constructors from regular methods in Java?

a) Constructors cannot be called directly
b) Constructors have a return type
c) Constructors cannot have parameters
d) Constructors are named after the class

Comments