🎙 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 2 of 10

In a shallow copy, what happens to a field that refers to another object?

In a shallow copy, what happens to a field that refers to another object?

  1. A.The referred object is copied too
  2. B.Only the reference is copied, so both objects share the inner object
  3. C.The field is set to null
  4. D.The field is skipped
Answer & explanation

Correct answer: Only the reference is copied, so both objects share the inner object

A shallow copy copies field values; for a reference field, the value is the reference.

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 →