Can some body please explain me about the interfaces.....? Does the interface contains variables, constructors...? Can it be instantiated...? I also have the following question, that i cannot understand...? Given the following classes, which of the following will compile without error...? interface IFace{} class CFace implements IFace {} class Base{} public class ObRef extends Base { public static void main(String argv[]) { ObRef ob = new ObRef(); Base b = new Base(); Object o1 = new Object(); IFace o2 = new CFace(); } } 1) o1 = o2; 2) b = ob; 3) ob = b; 4)o1 = b; The given answers are 1,2,4. Can somebody please explain about the 1.
Paul A
Ranch Hand
Joined: Aug 25, 2000
Posts: 44
posted
0
'o1' is a variable of class Object. As you know that all objects eventually extend from Object class, the object refered to by the variable 'o2' will also be an Object. So it is legal to set o1 to point to o2. For info about interface, I would suggest you to read Java Tutorial on Sun site. It is very good. ------------------ http://pages.about.com/jqplus Get Certified, Guaranteed!