Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions