java - Implementing multiple Interfaces -
in interface 1 have method a
, in interface 2 have method b
. both methods implemented in class three
. assign instance of 3 one, still can phone call method b
of second?
even if possbile, correct?
assuming have this:
public interface { public void methoda(); } public interface b { public void methodb(); } public class c implements a,b { public void methoda(){...} public void methodb(){...} }
you should able this:
a = new c(); a.methoda();
but not this:
a.methodb()
on other hand, can this:
b b = new c(); b.methodb();
but not this:
b.methoda();
edit:
this because define object a
of beingness instance of a
. although using concrete class initialization (new c()
), programming interface methods defined in interface visible.
java
No comments:
Post a Comment