- 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.

17th Apr 2017, 4:47 PM
Arbind Mandal
Arbind Mandal - avatar
3 Respuestas
+ 5
Homework: dislike ^^
17th Apr 2017, 5:20 PM
visph
visph - avatar
0
What is your actual question?
17th Apr 2017, 6:38 PM
T0nd3
- 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); } }
19th Dec 2020, 7:29 PM
Kalash Acharya
Kalash Acharya - avatar