• Post Reply Bookmark Topic Watch Topic
  • New Topic

Method call  RSS feed

 
Persian Sama
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
we have 1 interface A and 2 classes B and C that both implement A
my question is : if one class implement a method from the Interface A, is it legal to use directly that method on the other class ??
Thanks
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try it and see what happens.
 
Jacob Draper
Ranch Hand
Posts: 35
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm curious to see what you find. Please post after you experiment a little.

My guess is, the class that doesn't define the method will give an error because it needs to declare all the methods from the interface, or declare them as abstract. However, you could declare the method and call the other classes method inside that method so it would have the same function.

If you extended the other class then you would have a different story. I'll have to try some of this myself when I get the chance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!