i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes

Ads
 

i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes

import java.io.*;
interface arith
{
int a=5;
int b=8;
 void add();
 void mul();
 void sub();
 void div();
}
class addition implements arith
{
public void add()
{
int c=a+b;
System.out.println("method add"+c);
}
}
class multiplication implements arith
{
public void mul()
{
int d=a*b;
System.out.println("method mul"+d);
}
}
class subtraction implements arith
{
public void sub()
{
int e=a-b;
System.out.println("method sub"+e);
}
}
class divide implements arith
{
public void div()
{
int f=a/b;
System.out.println("method div"+f);
}
}
class exampleinterface
{
public static void main(String []arg)
{
arith s=new addition();
multiplication t=new multiplication();
subtraction u=new subtraction();
 divide v=new divide();
s.add();
t.mul();
u.sub();
}
}
View Answers

November 20, 2012 at 11:11 AM

Here is your code, we have modified it.

import java.io.*;
interface arith {
    int a=5; 
    int b=8; 
    void add(); 
    void mul();
    void sub();
    void div(); 
    } 
    class exampleinterface implements arith{
        public void add() {
            int c=a+b;
            System.out.println("method add: "+c);
            }
                public void mul() {
                    int d=a*b;
                    System.out.println("method mul: "+d); 
                    } 
                        public void sub() {
                            int e=a-b; 
                            System.out.println("method sub: "+e);
                            }
                                public void div() {
                                    int f=a/b;
                                    System.out.println("method div: "+f);
                                    }

                                        public static void main(String []arg) {
                                            exampleinterface s=new exampleinterface();

                                            s.add();
                                            s.mul();
                                            s.sub();
                                            s.div();
                                            s.div();
                                            }
                                            }

Ads









Related Tutorials/Questions & Answers:
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface... is your code, we have modified it. import java.io.*; interface arith { int a=5
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface... is your code, we have modified it. import java.io.*; interface arith { int a=5
Advertisements
i have got error while compiling simple tag handler
i have got error while compiling simple tag handler   javac.servlet.jsp not found! tell me what are the jar files required to run simple tag handler...;it is : javax.servlet.jsp only but getting error wt is reason
I developed a simple java web project in Struts now If I have to import the project in Eclipse Indigo how can I do it
I developed a simple java web project in Struts now If I have to import the project in Eclipse Indigo how can I do it   I developed a simple java... can I do it . Can some one please let me know . Thanks   Basically
I/O Program output error
seem to get that to work either. Can anyone offer some suggestions? I thank you...I/O Program output error  Hello All, I am working on a program... file, but I am getting incorrect output. I have been successfull with part
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........  code for a simple java program which performs basic arithmetic operation addition,subtraction
How can I show users privileges in MySQL?
How can I show users privileges in MySQL?  Hi, How can I show user's privileges in MySQL? I want to know what is accessible to user in MySQL... use following sql query: show grants for username; Here is simple usage
how i can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
instead of text boxe i have to show check box as selected.
instead of text boxe i have to show check box as selected.  i have... the database. when ever the valsue is there in textfield, instead of text boxe i have to show check box as selected. Thanks In advance R.Raveen.
i got an error while compile this program manually.
i got an error while compile this program manually.  import... mapping.findForward("errors.jsp"); } } i set both servlet,struts jar files and i got an error in saveErrors() error Heading cannot find
in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit.
in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit.  in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit. Thanks In Advance   Please
I am getting error.How can i get details
I am getting error.How can i get details  Exception in thread "main" java.sql.SQLException: Listener refused the connecti n with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect
how can i hide and show tables
how can i hide and show tables  hai, i am creating a form which the code is included below i want to hide the tables initially and after i click go...;/html>   You can use javascript. Here is an example of simple jsp code
How can I get IBM certification for free?
How can I get IBM certification for free?  Hi, I am beginner in Data...: How can I get IBM certification for free? Try to provide me good examples or tutorials links so that I can learn the topic "How can I get IBM
How can I get into big data?
How can I get into big data?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can I... can learn the topic "How can I get into big data?". Also tell me
Can I get a job with just python?
Can I get a job with just python?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Can I... so that I can learn the topic "Can I get a job with just python?"
Can I learn Python at 45 and get a job?
Can I learn Python at 45 and get a job?  Hi, I am beginner in Data...: Can I learn Python at 45 and get a job? Try to provide me good examples or tutorials links so that I can learn the topic "Can I learn Python at 45
How do I get a job as a data scientist if I have no prior experience?
that I can learn the topic "How do I get a job as a data scientist if I have...How do I get a job as a data scientist if I have no prior experience? ... for the tutorials to learn: How do I get a job as a data scientist if I have
i have problem in that program to my assignment sir - JavaMail
i have problem in that program to my assignment sir   Develop a programmer's editor in Java that supports syntax-highlighting, compilation support, debugging support, etc
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.  in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar
Can I have multiple main() methods in the same class?
Can I have multiple main() methods in the same class?  Hi, Can I have multiple main() methods in the same class?   Hi, No, We cann't use multiple main() method within the same class. If we do this then the program
I have crude application
I have crude application   I have crude application, how to load into this roseindia.net
How can I get specific data from JSON
How can I get specific data from JSON  Hi, How can I get specific data from JSON? Thanks
there are class A & class B.How can i get members of class A& B?
there are class A & class B.How can i get members of class A& B?  there are class A & class B.How can i get members of class A& B
If Sessin Contain Array how can i get each value.
If Sessin Contain Array how can i get each value.  sir, i m trying to get value form session and session contain array i mean .. whatever... to use this value in different conditions..so how can i get it.. Thank u
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
can i know the error in this code... am unable to run this code
can i know the error in this code... am unable to run this code  ...}; int n=arr.lenght; System.out.println("length of array:"+n); for(int i=0;i System.out.println(arr[i]); } }   You have used incorrect symbol in your
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
How can I get query string values in JavaScript?
How can I get query string values in JavaScript?  How can I get query string values in JavaScript?   To get a query string value, you can use JQuery and JavaScript.. here is the code: function getParameterByName(name
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I retereved 5 Employee Record of Data from Struts Action class to jsp with ajax response. But I don't how how can reterve this dynamic 5 employee records

Ads