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 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();
                                            }
                                            }









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 have split a string by space ,done some operation and now how to properly order them for sending a mail in java or jsp - JSP-Servlet
i have split a string by space ,done some operation and now how to properly order them for sending a mail in java or jsp  Dear sir, I have a text area in that i typed a some matter this is in one jsp .Then i got
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 have problem in that program - JavaMail
i have problem in that program  1. Write a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a thread that generates prime
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
i have problem in that program sir - JavaMail
i have problem in that program sir  1.Develop multi-threaded echo server and a corresponding GUI client in Java
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
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.
Can you see what i have done because i did it but i still have problem - SQL
Can you see what i have done because i did it but i still have problem  This is what i have done but i still have a problem:- Can you correct my mistakes? ------------------------------------------------------- create database
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
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
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
how i can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
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
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
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 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
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
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
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
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
arithmetic operation on float number
arithmetic operation on float number  hi here is my code class... output like "0.1999998092". but I want to show output like "0.20".why compiler...; System.out.println(dou); } } I convert Double Value DUB=14.2 into integer variable NUM
Write an event driven program to perform the arithmetic operations as shown in the interface
Write an event driven program to perform the arithmetic operations as shown in the interface  hi sir i have an assignment question, but i don't know... an event driven program to perform the arithmetic operations as shown
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
i am confused here on what to write can some 1 help out here - Java Beginners
i am confused here on what to write can some 1 help out here  i don't quite understand how to code it so can some one help out
I have problem in my Project
I have problem in my Project  Dear Sir, i have problem in my project about Jtable i have EDIT JButton whenevery i was click on edit he is display all data from database but i want to select any row
how can i write this program ?please suggest me
how can i write this program ?please suggest me  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
I have to retrieve these data from the field table
I have to retrieve these data from the field table  Hi. I have... chennai,trichy,kanchipuram for a single record. I have to retrieve these data from... as single values like chennai as one value, trichy as one value. and i have
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 an ques. of advanced java
i have an ques. of advanced java  write a wap to implement AWT by login form
I have doubt in jsp file.
I have doubt in jsp file.  I have doubt in jsp file. In a jsp file, there should be two buttons. One is start and other is stop. When we click.... Please can you help me with the code
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
Will i be able to get the content of a webpage in a word document (Note:i don t have access to the source code)through java code?
Will i be able to get the content of a webpage in a word document (Note:i don t have access to the source code)through java code?  public class... document to the webpage(for which i don t have access to source code
i have a problem in spring - Spring
i have a problem in spring  spring Aop: how to configure proxyfactorybean in xml file for providing advices for one particular class
program created and compilation error of connection rightly created n tested
program created and compilation error of connection rightly created n tested  // I have made connection as the data source dsn2 and i have also... ("there was some error in establishing connection : "+e); } sep
How can I open my Java desktop app by clicking on its file?
How can I open my Java desktop app by clicking on its file?  How can I open my Java desktop app by clicking on the file it creates? This app creates... and make its text files save as "*.bsky" files. What must I do to make this *.bsky
How can I get the full URL with the attached parameters? - JSP-Servlet
How can I get the full URL with the attached parameters?  Hi, I'm trying to figure out how to get the current url and use it in my jsp page. I...:8080/MesEduSchoolsProject/displayMenu.jsp How can I get the full URL with the attached parameters
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
Can I get a job with Google IT support professional certificate?
Can I get a job with Google IT support professional certificate?  Hi... for the tutorials to learn: Can I get a job with Google IT support professional... learn the topic "Can I get a job with Google IT support professional
Where can I get best Data science training with project work?
Where can I get best Data science training with project work?  Hi, I... for the tutorials to learn: Where can I get best Data science training with project... the topic "Where can I get best Data science training with project work
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

Ads