aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes problem with interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "problem with interface" Watch "problem with interface" New topic
Author

problem with interface

Reshma Das
Ranch Hand

Joined: Jan 29, 2002
Posts: 125
I have a problem with interfaces.
interface A {
}
interface B extends A {
public methods of Data
}
interface C extends A,Remote {
public methods of Data throws RemoteException
}
class Data implements B {
...
}
class server implements C {
}
class client {
A a;
clein() {
if (local)
a = new Data();
else
a = (A)Naming.lookup(.....);
Iam getting compilation errors saying methods defined in B or C can be accessed using A.
Iam i wrong in understanding interface concepts ?
amit ahuja
Ranch Hand

Joined: Nov 20, 2001
Posts: 38
Originally posted by Reshma Das:
Iam getting compilation errors saying methods defined in B or C can be accessed using A.
Iam i wrong in understanding interface concepts ?


I presume u the compilation error says "methods defined in B or C canNOT be accesses using A"
if that's the case, then compiler is right, u cannot do so, though u can access methods of A from B or C.
Simple inheritence...
Reshma Das
Ranch Hand

Joined: Jan 29, 2002
Posts: 125
i know there is a problem in this . Can someone explain me how to handle this situation of writing 2 different interfaces for remote & local client. Iam confused on this part.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Reshma, there should be only one interface. The one that has all the public methods of the Data class, then there are 2 class one for local and one for remote that implement this interface.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Reshma Das
Ranch Hand

Joined: Jan 29, 2002
Posts: 125
Mark,
Right now I did the same. One interface which says
interface A extends Remote {
method1 throws RemoteException();
.....
}
and my server and data class implements this interface.
I think for local client we should not use Remote, RemoteException. Iam struck with this point. Can u pls suggest me something ?
 
jQuery in Action, 2nd edition
 
subject: problem with interface