fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. interface Animal {
  8. public void eat();
  9. }
  10.  
  11. interface Dog extends Animal {
  12. public void woof();
  13. }
  14.  
  15. interface Cat extends Animal {
  16. void meow();
  17. }
  18.  
  19. static class Poppy implements Dog {
  20. public void eat() {}
  21. public void woof() {}
  22. }
  23.  
  24. static class Dazy implements Cat {
  25. public void eat() {}
  26. public void meow() {}
  27. }
  28.  
  29. static void replace(Animal animal) {
  30. animal = new Poppy();
  31. }
  32.  
  33. public static void main (String[] args) throws java.lang.Exception
  34. {
  35. Cat cat = new Dazy();
  36. replace(cat);
  37. cat.meow();
  38. }
  39. }
Success #stdin #stdout 0.06s 32272KB
stdin
Standard input is empty
stdout
Standard output is empty