Code: Select all
interface Eatable {
int types = 10;
}
class Food implements Eatable {
public static int types = 20;
}
public class Fruit implements Eatable {// LINE1
public static void main(String[] args) {
types = 30; // LINE 2
System.out.println(types); // LINE 3
}
}
Fruit does not extend Food in the given codeCompilation failure at //LINE 1 as well as at //LINE 3
Class Fruit implements Eatable as well as extends Food.
Shouldn't the answer be: Compilation failure at //LINE 2 ?
javac returns:
Fruit.java:13: error: cannot assign a value to final variable types
types = 30; // LINE 2