Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


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'?

  1. It is modified as well

  2. It remains unchanged

  3. It is nullified

  4. It gets a copy of modifications made to 'a'

The correct answer is: 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.