1.class Foo { Bar bar;}
This is incorrect, as we cannot say for sure if Bar is an object type from which concrete instances are made, or if bar in an interface. Regardless, at runtime, an object that is-a bar is required, regardless of whether Bar is an interface, abstract class, or concrete class. If Bar is an interface, at runtime, the class implementing the Bar interface will indeed be an Object.
2.class Bar { }
All classes inherit from java.lang.Object, meaning in this case Bar is-a type of Object.
3.class Foo extends Bar{ }
Classes can only inherit from other classes, so in this case, Bar is either an abstract class, or a concrete class, both of which would have java.lang.Object as an ancestor, so in this case, Bar is-a type of object.
4.class Bar extends Foo{ }
All classes in
Java extend java.lang.Object as their most distant ancestor. In this case, Bar is a class, so it is-a type of Object.
So, 1 is pretty iffy, whereas 2,3 and 4 are all positively objects.
You might want to take my OOA & D quiz on
www.scja.com There are more questions (and answers) on the subject there.
Cheers!
-Cameron McKenzie
[ November 06, 2006: Message edited by: Cameron W. McKenzie ]