• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with interface

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Reshma Das
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
I don't like that guy. The tiny ad agrees with me.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic