Mastering Java: The Ultimate 2025 All-In-One Quiz to Excel in 'Thinking in Java

Image Description

Question: 1 / 510

If 'a' is an object and 'b' is an object and you assign 'a = b;' in Java, and then modify 'a', what happens to 'b'?

It is modified as well

When we assign 'a = b;' in Java and then modify 'a', 'b' is also modified because both 'a' and 'b' are referencing the same object. Therefore, any changes made to 'a' will also be reflected in 'b'. Option B is incorrect because 'b' is not a copy of 'a' but rather a reference to the same object. Option C is incorrect because the assignment of 'a' to 'b' does not nullify 'b' in any way. Option D is incorrect because 'b' does not get a copy of modifications made to 'a', but rather the original modifications themselves.

Get further explanation with Examzify DeepDiveBeta

It remains unchanged

It is nullified

It gets a copy of modifications made to 'a'

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy