fork download
  1.  
  2. class A {
  3. void test() {
  4. System.out.println("One");
  5. }
  6. }
  7.  
  8. interface J {
  9. void first();
  10. }
  11.  
  12. class B extends A { // This class object can referenced using A like A a = new B()
  13. // code
  14. }
  15.  
  16. class B implements J { // // This class object can referenced using J like J j= new B()
  17. // code
  18. }
  19.  
  20. // my question is what happens in case of below which referencing for runtime polymorphism ??
  21. class B extends A implements J {
  22. // code
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:16: error: duplicate class: B
class B implements J { // // This class object can referenced using J like J j= new B()
^
Main.java:21: error: duplicate class: B
class B extends A implements J {
^
2 errors
stdout
Standard output is empty