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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!