Saturday, January 13, 2007

dummy interview question

is this code:
A)
a1 = new SomeClass();
a2 = new SomeClass();

equivalent to:
B)
a1 = a2 = new SomeClass();

??
(explain why)

The trick is how you ask the question, if you asked "what's the difference between option a and option b?" you are already telling them there is a difference.

1 comment:

Ayende Rahien said...

You are creating two instances in the first case, only one in the other.

1/ a1 != a2
2/ a1 == a2