Question
public interface Z { int foo(int i, int j); int bar(String s); } public class A implements Z { @Override int foo(int x, int y)
public interface Z {
int foo(int i, int j);
int bar(String s);
}
public class A implements Z {
@Override
int foo(int x, int y) {
return x;
}
@Override
int bar(int s) {
return s+1;
}
}
public class B implements Z {
@Override
void foo(int i, int j) {
int z = i + j;
}
}
In the above program (consisting of interface Z, class A, and class B), mark which of the following are its compiler errors?
A.foo names the arguments x,y instead of i,j
A.bar should take a String as its argument not an int
B.foo must return int not void
Two classes cannot implement the same interface (Z)
Z.foo and Z.bar are missing code inside the methods
foo cannot be defined twice in both A and B
B must have a method "int bar(int)"
B must have a method "int bar(String)"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started