Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ezhumalai
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
1 Answer(s)      2 years ago
Posted in : Java Beginners


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

Advertisement
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
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 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 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 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
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
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 sir - JavaMail
i have problem in that program sir  1.Develop multi-threaded echo server and a corresponding GUI client in Java
how i can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
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
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.
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
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
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
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
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
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 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
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 crude application
I have crude application   I have crude application, how to load into this roseindia.net
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 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
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
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 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
how can i get output pls urget tell me
how can i get output pls urget tell me  HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception
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
 

 

 

DMCA.com