🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Shallow and Deep Copy: all 10 questions

Quiz: Shallow and Deep Copy · Question 8 of 10

Why do many Java developers prefer a copy constructor over clone()?

Why do many Java developers prefer a copy constructor over clone()?

  1. A.Copy constructors are always faster
  2. B.It runs normal constructor code, works with final fields and needs no cast or checked exception
  3. C.clone() was removed from Java
  4. D.Copy constructors make deep copies automatically
Answer & explanation

Correct answer: It runs normal constructor code, works with final fields and needs no cast or checked exception

A copy constructor is ordinary code where you decide how each field is copied.

Can you get the rest right without peeking?

Take the timed Quiz: Shallow and Deep Copy quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →