- 1
interface named num with two functions int add (int x, int y) and int diff(int x, int y) then make a class the implements that.
3 Answers
+ 5
Homework: dislike ^^
0
What is your actual question?
- 1
This seems like an incomplete question. I've come across a similar question, that is " Make an interface named num with two functions int add(int x, int y) and int diff(int x, int y) then make a class that implements that interface num. ".
Here is the solution for this:
interface num {
int add(int x, int y);
int diff(int x, int y);
}
class InterfaceByKalash implements num {
int sum;
int sub;
public int add(int x, int y) {
sum = x+y;
System.out.println("The sum is = " +sum);
return sum;
}
public int diff(int x, int y) {
sub = x-y;
System.out.println("The difference is = " +sub);
return sub;
}
public static void main(String[] args) {
Interface2015 obj = new Interface2015();
obj.add(2, 4);
obj.diff(2, 4);
}
}