Modify the given codes to remove the compilation errors. (2 items x 5 points)
1.
public interface Carnivore {
int pieces = 10;
public static void eatGrass();
public int chew() {
return 13;
}
}
2.
interface Haswings {
public int getNumberOfWings();
}
abstract class Insect implements HasWings {
abstract int getNumberOfLegs();
}
public class Dragonfly extends Insect {
int getNumberOfLegs() {
return 6;
}
}
SOLUTION CODE
interface Carnivore {
int pieces = 10;
public static void eatGrass()
{}
public int chew();
}
interface HashWings {
public int getNumberOfWings();
}
abstract class Insect implements HashWings {
abstract int getNumberOfLegs();
}
class Dragonfly extends Insect {
int getNumberOfLegs() {
return 6;
}
@Override
public int getNumberOfWings() {
return 0;
}
}
Comments
Leave a comment