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

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)      a year and 8 months 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
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 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
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
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 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
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
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
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
Can I pass a
Can I pass a   Suppose I have servlet named Name.java and there is a variable String name holding a value "Roseindia". I have collected the value to Getname.jsp via ajax. Now how can I pass this value to scriplet without page
I am trying to develop a Image Sliding application but unfortunately its not working... Can any one help me in this
I am trying to develop a Image Sliding application but unfortunately its not working... Can any one help me in this  Can Anyone Help Me In This import java.awt.*; import javax.swing.*; import java.awt.event.*; class SlideShow
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
how can i define only one method from the interface. - Java Beginners
how can i define only one method from the interface.  If i am having an interface with 3 methods(declaration) . If i want to use only one method... the solution for that. please i want it immediately.  Hi friend
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
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
I face some problem - Java Beginners
I face some problem  I face some problem in my project plz deepak halp me how can i solve this problem i m using bean and jsp file also. and deployee the using tomcat server plz help me how can i solve thisproblem HTTP Status
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
DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality.
DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality.  DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality. What can I do
i am Getting Some errors in Struts - Struts
i am Getting Some errors in Struts   I am Learning Struts Basics,I am Trying examples do in this Site Examples.i am getting lot of errors.Please Help me
How can I learn Java?
How can I learn Java?  Hi, I have just completed a course in HTML and C programming language. I have some programming experience in visual basic... programming. How can I learn Java? in shortest possible time. I mean I just want to begin
what is wrong in this program?I have netbeans 7.0 & jdk 7. please do corrections.
what is wrong in this program?I have netbeans 7.0 & jdk 7. please do corrections.  import java.io.*; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.List
i need some help in understanding the following codes.thanks..
i need some help in understanding the following codes.thanks..  this code is to perform LocalColorHistogram.But i can't understand it public... * height; int i = 0; int j = 0; int k = 0; double
Advertisements
 

 

 

DMCA.com