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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


faiyaz khan
java prg
2 Answer(s)      3 years and 5 months ago
Posted in : Java Interview Questions


how to write a program in java for add two number without using increment and arithmetic operator.


Advertisement
View Answers

July 25, 2011 at 10:40 AM


import java.math.*;
class AddNumbers 
{
    public static void main(String[] args) 
    {
        BigInteger num1=new BigInteger("100");
        BigInteger num2=new BigInteger("50");
        BigInteger result=num1.add(num2);
        System.out.println(result);
    }
}


July 25, 2011 at 10:41 AM


public class AddNumberUsingBitwiseOperators {
    public static void main(String[] args) {
        System.out.println("Adding 5 and 6......");
        int x=5,y=6;
        int xor, and, temp;
        and = x & y;
        xor = x ^ y; 

        while(and != 0 ){
            and <<= 1; 
            temp = xor ^ and;
            and &= xor; 
            xor = temp; 
        }
        System.out.println(xor);
        }
        }


Related Tutorials/Questions & Answers:
java prg
java prg  how to write a program in java for add two number without using increment and arithmetic operator.   import java.math.*; class AddNumbers { public static void main(String[] args
prg
Advertisements
File Handling - Java Beginners
File Handling  Q. Write a java prg which accepts a list of existing... the existing prg import java.io.*; class FileCopy { public static void main(String...(e.getMessage()); } } }   its prg of copying file Check code
How to use Java Beans in JSP?
How to use Java Beans in JSP?  Hi, I have developed a employee bean in Java: public class Employee{ private String name; private String code; ..... } Please tell me how I can use Employee Java bean in JSP page? Thanks
FileHandling - Java Beginners
FileHandling  Q. Write a java prg which accepts a list of existing text files from command line args & concatinate contents of all files... prg import java.io.*; class FileConcat { public static void main
servlet program problem - Java Beginners
servlet program problem   i used ur servlet example prg with xml file of helloworld program and i run dat program in tomcat, it shows only the files in my specified directory but when i clicked dat file name it just displaying
java
java  diff bt core java and java
java
java  what is java
Java
Java   Whether Java is pure object oriented Language
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
Advertisements
 

 

 

DMCA.com