DSA Factory
Free Object-oriented basics lessonsObject-oriented basics · Stage 0 · Objects and references · Step 1

Classes, objects and references

The difference between a class and an object, what a variable really holds, and why == and equals are not the same. About 13 minutes.

Quick check

Point a = new Point(1, 2); Point b = a; a = null; What is b?

  1. AStill the Point object: only a's reference was cleared
  2. Bnull, since it was the same object
  3. CIt throws an exception
Show the answer

Still the Point object: only a's reference was cleared. Setting a to null removes one arrow; b's arrow still points at the object.

Lock it in

4 questions on this idea

Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.

Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve