LearnFrenzy
Sign in Take a free test

Constructors and the this Keyword · Exercise 1 of 4

Constructors and the this Keyword Constructors MCQ

  • 20 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twenty multiple-choice questions on Java constructors and the this keyword: default constructors, overloading, this() chaining, initialisation order, private constructors, copy constructors and builders. Pick an option to check your answer instantly.

Question 1 Easy

What is the return type of a constructor?

A void
B It has no return type at all
C The class type
D Object
Question page & discussion
Question 2 Easy

What must a constructor's name be?

A Anything starting with init
B Exactly the same as the class name
C new
D constructor
Question page & discussion
Question 3 Easy

When does the compiler provide a default (no-arg) constructor?

A Always
B Only when the class declares no constructors at all
C Only for public classes
D Only when all fields are final
Question page & discussion
Question 4 Medium

What does the compiler-generated default constructor do?

A Sets all fields to null
B Calls the superclass no-arg constructor (super()); fields keep their initial values
C Nothing – it is empty with no super call
D Prints the class name
Question page & discussion
Question 5 Easy

What is constructor overloading?

A A constructor calling itself
B Having several constructors with different parameter lists
C Overriding the parent constructor
D A constructor with too many parameters
Question page & discussion
Question 6 Medium

On Java 21, where must a this(...) call appear?

A Anywhere in a method
B As the first statement of a constructor
C As the last statement of a constructor
D Only in static blocks
Question page & discussion
Question 7 Easy

Inside an instance method or constructor, what does this refer to?

A The class
B The current object
C The parent object
D The last created object
Question page & discussion
Question 8 Easy

Why do constructors often contain this.name = name;?

A It is required syntax
B The parameter name hides the field, so this.name is needed to refer to the field
C It makes the field final
D It copies the object
Question page & discussion
Question 9 Medium

Which modifier can be used on a constructor?

A static
B private
C final
D abstract
Question page & discussion
Question 10 Medium

Which is a typical use of a private constructor?

A Making fields private
B Preventing outside code from creating objects – for utility classes, singletons, or creation through factory methods and builders
C Speeding up construction
D Allowing inheritance
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links