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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

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.


What type of variables does the assignment with primitives in Java affect?

  1. Object references

  2. Primitive values directly

  3. The class variables

  4. Java does not allow assignment with primitives

The correct answer is: Primitive values directly

When assigning a primitive value in Java, the assignment affects the primitive value directly. This means that any changes made to the assigned variable will directly affect the assigned value and not any other references or class variables. This is different from assigning object references, which affect the reference to an object rather than the actual object itself. Java does allow assignment with primitives, contrary to option D, which is why option B is the correct answer.