Guest User

Untitled

a guest
Jan 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. interface A{
  2. default public void method1(){
  3. System.out.println("method1 printing from interface A");
  4. }
  5. default public void method2(){
  6. method1(); // note that method1() is overriden in class C.
  7. // which one should be called? from A or C?
  8. }
  9. }
  10.  
  11. interface B extends A{
  12. void methodWhichCallsMethodOnInterface();
  13. }
  14.  
  15. class C implements B{
  16. @Override
  17. public void method1(){
  18. System.out.println("method1 printing from class C");
  19. }
  20.  
  21. @Override
  22. public void methodWhichCallsMethodOnInterface(){
  23. method2();
  24. }
  25. }
  26.  
  27. B b;
  28. b.methodWhichCallsMethodOnInterface();
Add Comment
Please, Sign In to add comment