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

 
 


Ezhumalai
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
1 Answer(s)      6 months and 5 days 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();
}
}
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 Pages:
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
Mistakes To Be Avoided While Writing Articles
necessary. Just imagine how boring it may get if you have to read a huge text blob... as these boxes usually get a CTR of about 3%. Hence, its advantage must.... Interest can only be created in the reader's mind if the article headline
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
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
MISTAKES CORRECTION - Java Beginners
; hai frnd.... thats not an issue.. you can run the program without..., as you have advised. Once again I submit my heartfelt thanks to you all...MISTAKES CORRECTION   Dear Sir, The under mentioned
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
Interface
Interface  Can Any one Give the exact program explanation...) and variables within it. Here is an example where we have defined an interface and implements its methods (which are declared in interface) int the class. interface Ex
Top 10 SEO Mistakes,Common Mistakes in Search Engine Optimization,Search Engine Marketing Mistakes
in the search engines are due to very simple mistakes in designing the web site... Search Engine Mistakes - Search Engine Optimization Mistakes... to the web site. If your content is good then the chances are very high to get
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
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
please tell the reason for java.lang.ArrayIndexOutOfBoundsException: in program
{ public static void show(int x[][],int y[][]){ for(int i=0 ; i <...please tell the reason for java.lang.ArrayIndexOutOfBoundsException: in program  public class Test { public static void show(int x[][],int y
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
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
A Simple program
A Simple program  Hi I have written the following code: class...; Thanks for the solution. Now its working. One more thing I need to ask: Is there any provision by which I can directly use farea and sarea for calculating
Arithmetic Testing for School Students
Arithmetic Testing for School Students In this section, we have created.... This application allows the student to select the arithmetic operation... the student is asked to enter the answer for the arithmetic operation applied to the two
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
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
interface
interface   Hi I have interface in that interface 3 methods are there , after some days client said that,i want to add one more method in that interface ,so how can add 4 method so that the implemented class did not affect
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
Java Interface
a class can implement one and more interfaces. Suppose I have created... { public void show(); } Now, I have created a class that implements... by its subclasses or implementing classes. The public interface can
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
Java Get Example
In this example java program we have to get the data type of the database table fields.   Show current date  In this example program we have to get... program to get the Command Line Arguments In java we can get
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
JSP Simple Examples
is a sequence of simple characters. We can get the length... class. By using this method we can get more information about... We can have more than one try/catch block. The most specific
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
GUI Tutorial I - FIRST DRAFT
need clear plans, can easily patch up mistakes, etc. Building a house requires.... A good choice for simple programs is to terminate the program. 1... of the call to setVisible(true), A GUI program builds the user interface, then just
can interface solve this problem in java
can interface solve this problem in java  I have a JDialog which displays the calendar [from 2010-2020], i created this in a different class.... Now i need to get which day is clicked by the user from another class which calls
Java I/O Assistance + Loop
and append all odd numbers 1-100 and finally close file. But for some reason I CANNOT Get the output as I want. I know where the error lays I just can't seem...Java I/O Assistance + Loop  I'm trying to make this program write
Java: Example - Simple Calculator
(Calc.java) - A simple main program. User interface (CalcGUI.java... place. Altho this simple example doesn't show the full power of separating... interface. The model can be changed (eg, to work with BigInteger) without
Simple Program Very Urgent.. - JSP-Servlet
Simple Program Very Urgent..  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your superb reply. I find a simple problem which i have tried my level best to solve.In the output, the text box is receiving some other value
Some Notes on Java Programming Environments
programmer should have some experience with IDEs, but I think that it's an experience... interface program that integrates all these aspects of programming and probably... be typed in to edit files, compile source code, and run programs. I have
File I/O
File I/O  i have a problem i am trying to print on a new line every... this Creating Finally, its time to write some code. Bookmark the Google APIs... Finally, its time to write some code. Bookmark the Google APIs Add-On Javadocs
The Arithmetic Operators
to calculate arithmetic operation. The java programming tutorial provide operators..., and division.  Description of program: In this section we will get the arithmetic values. First of all, we have to define class named "
how can i display a editable result of form?
to display form result in same page i have alredy created a hidden div which show the result but i can not modify the result. how can i display modifyable...how can i display a editable result of form?  how can i display
MISTAKES CORRECTION - Java Beginners
is as below but i did not got any error and applet got initilized: import...MISTAKES CORRECTION  Dear Sir, As you Advised, without compiling, I run the programee with the undermentioned HTML codes in Internet
Arithmetic Operators
Arithmetic Operators       Arithmetic Operators are used to perform some mathematical... String". Lets have one more example implementing all arithmetic operators
Programming: Hammurabi I - Project start
Java: Programming: Hammurabi I - Project start Copy these files to start your project The Hammurabi I program may require a number of things that you... the Kingdom class doesn't have any code to work the the population. Some areas
Java I/O From the Command Line
Standard Error : Standard Error can be gotten using System.err System.out... of the console object returns null then the console operation can not be done by either of the reason : Operating System is not supported them If the program
simple program question
simple program question  how do i get a java program to take an input from the user and have it terminate by a period and not by pressing enter
GUI Interface .Reply me with in hour..Its Urgent - Java Beginners
GUI Interface .Reply me with in hour..Its Urgent  Hi ... Now i am doing project for Voting finger print Authentication .. Can any pls assit me.. I have to create GUI Interace ..How should i create the Interface. In Existing
Error in simple session bean ..................
Error in simple session bean ..................  Hi friends, i am trying a simple HelloWOrld EJb on Websphere Applicatiopn server 6.1. Can any one plz help me to solve this issue. here is the client code which i have
Null value when i set interface object in form controller - Spring
("ohbillManager "+this.ohbillManager); } and another error i unable to manipulate data with new table , i can do CRUD operation operation with new table...Null value when i set interface object in form controller   Hi all
Programming: Hammurabi I
you have the simple version of the program running as described above, you might... Java NotesProgramming: Hammurabi I Description Your program will simulate... of a bad harvest. Initial Conditions Your program should create
Using JOINING Operation in JDBC
a join operation. Tables in a database can be related to each other with keys... are the two aliases of tables we have created. They represents the tables... method is used to show error messages. If the connection is not connected
How can i select a particular item in jpopup menu through java programs
How can i select a particular item in jpopup menu through java programs  Good day Friends .... I have a doubt in jpopupmenu. That how can i sow a perticular menu item in jpopup menu to be selected. I created a gui where it has
Exception Handling-Error Messages in Program
Exception Handling-Error Messages in Program  Hi Friend, I am having...[]) throws Exception{ This is where I begin to see problems with error messages...","C","D","F","I"}; ^ ArrayList.java:6: 'class' or 'interface' expected List l
Java I/O Byte Streams
Java I/O Byte Streams In this section we will discussed the I/O Byte Streams... are used where the program needs to work with the raw binary data. In Java to handle I/O raw binary data the byte stream classes are defined. For all of the byte
Programming: Hammurabi I - Solution
Java NotesProgramming: Hammurabi I - Solution Solution The following two source files are a solution to the Hammurabi I programming problem. This solution has expanded somewhat on the minimum requirements. Main program 1 2

Ask Questions?

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.