
hai
I have defined one inter face like Maths taking methods like add(), sub(), mul()in interface
I take different implementation classes for add() method and sub()and mul()
when i trying to implement add()mthod in Addition class it is asking sub() and mul() methods which are define in Maths interface. I want only addition implementation in addition class
how to resolve this

If you are implementing an interface in your java code, then you need to implement all its methods in a class. But if you want to use only add() method in your Addition class then implement three interfaces in your java code with three different methods.
Check the given code:
interface Maths1{
void add();
}
interface Maths2{
void sub();
}
interface Maths3{
void mul();
}
class Addition implements Maths1 {
public void add() {
int a=6,b=4;
int sum=a+b;
System.out.println(sum);
}
}
class Subtraction implements Maths2 {
public void sub() {
int a=6,b=4;
int diff=a-b;
System.out.println(diff);
}
}
class Multiplication implements Maths3 {
public void mul() {
int a=6,b=4;
int multiply=a*b;
System.out.println(multiply);
}
}
public class InterfaceExample{
public static void main(String[]args){
Addition a=new Addition();
a.add();
Subtraction s=new Subtraction();
s.sub();
Multiplication m=new Multiplication();
m.mul();
}
}

thank you
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.