java prg

Ads

 
 

Share on Google+Share on Google+

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

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

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

Ads









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
java
java  diff bt core java and java
java
java  what is java
JAVA
JAVA  how the name came for java language as "JAVA
java
java   why iterator in java if we for loop
java
java  explain technologies are used in java now days and structure java
java
java  different between java & core java
Java
Java   Whether Java is pure object oriented Language
java
java  is java open source
java
java  what is java reflection
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
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   What is ?static? keyword
java
java  RARP implementation using java socket
java
java  sample code for RARP using java
java
java  Does java allows multiline comments
Java
Java  how to do java in command prompt
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  Write a java code to print "ABABBABCABABBA
java
java  write a program in java to acess the email
java
java  send me java interview questions
java
java  how use java method

Ads

 
Advertisement null

Ads