Loading
Java - Constructors and Methods

Q1.

Which of the following is true about a constructor?

A. Must have a return type

B. Name can be different from class

C. Initializes objects
D. Cannot be overloaded

Q2.

Which of the following is a valid constructor declaration?

A. void Person() {}

B. Person() {}
C. int Person() {}

D. Person(int a) void {}

Q3.

Which statement about methods is correct?

A. Methods cannot return a value

B. Methods must have a return type (void if nothing returned)
C. Method name must match class name

D. Methods are automatically called at object creation

Q4.

Which of the following can be overloaded in Java?

A. Constructor
B. Method
C. Both Constructor and Method
D. Neither

Q5.

Which of the following is a key difference between a constructor and a method?

A. Constructor has a return type, method does not

B. Constructor name matches the class, method name can be any valid identifier
C. Methods cannot be overloaded

D. Constructors cannot initialize objects