This is a snippet of Java code:
interface Rideable {
String getGait();
}
public class Camel implements Rideable {
int x = 2;
public static void main(String[] args) {
new Camel().go(8);
}
void go(int speed) {
System.out.println((++speed * x++) + this.getGait());
}
String getGait() {
return " mph, lope";
}
}
It turns out that compilation fails (according to Oracle) though in my opinion it shall run fine producing output. So, where is the culprit for failing compilation?
Cheers
You can’t reduce the visibility of methods you override (interface methods are
publicby default), try this instead: