Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

abstract interface does not compile | Java

sry for the title, but why does the title not compile

1.    public abstract interface Herbivore {
2.            int amount = 10 ;
3.            public void eatGrass();
4.            public abstract int chew() { return 13; } 
5.   }
6.            
7.   abstract class IsAPlant extends Herbivore {
8.            Object eatGrass (int season) { return null;}
9.   }

thanks for helping

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The reason why it not compile

Line 4 does not compile, since an abstract method cannot include a body.

Line 7 also does not compile because the wrong keyword is used. A class implements an interface

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading