Interface
-
Hi friends, While going through Interface topic I came across this doubt..say there is a class called Myclass which implements an interface called ImyInterface..there is a line of code: ImyInterface xyz=new Myclass() can u plz explain me what this line of code actually means in terms of object and reference. Warm Regards, Rahul
-
Hi friends, While going through Interface topic I came across this doubt..say there is a class called Myclass which implements an interface called ImyInterface..there is a line of code: ImyInterface xyz=new Myclass() can u plz explain me what this line of code actually means in terms of object and reference. Warm Regards, Rahul
Normally base class pointer can point to a derived class object. Here, "new MyClass()" is a derived class Object(since MyClass implements ImyInterface ) and "xyz" is the base class pointer. MyClass will implement(define) functions in the Base interface.It can also contain its own new functions. Even though "xyz" points to an object which contain many functions,through "xyz" we will be able to call only the functions present in the interface.
Regards, Arun Kumar.A
-
Hi friends, While going through Interface topic I came across this doubt..say there is a class called Myclass which implements an interface called ImyInterface..there is a line of code: ImyInterface xyz=new Myclass() can u plz explain me what this line of code actually means in terms of object and reference. Warm Regards, Rahul
it means nothing or if it means something, there are only two options: 1. it's error 2. the two classes are inherited! but i'm not really sure of this option!