can we add two numbers without using arthematic operators?
if possible how?
Answers were Sorted based on User's Feedback
Answer / mohan
public static int addIterative(int a, int b){
while (b != 0){
int carry = (a & b) ; //CARRY is AND of two bits
a = a ^b; //SUM of two bits is A XOR B
b = carry << 1; //shifts carry to 1 bit to calculate sum
}
return a;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / g ch vishnu vardhan reddy
we can add two no's by using shift operator.
| Is This Answer Correct ? | 2 Yes | 4 No |
Answer / anandhakrishnan
import java.io.*;
class add
{
public static void main(String args[])
{
int a = 6;
int b = 3;
System.out.println("sum of a and b is :: "+(a|b));
}
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / satya
Hi we can add two number with out using arithemaic
operators.
just give
int a = 10;
int b = 5;
System.out.println("sum of a and b is :: "+(a|b))
| Is This Answer Correct ? | 10 Yes | 21 No |
What is difference between static and abstract class?
Can we use synchronized block for primitives?
Write a program in java to find the maximum and minimum value node from a circular linked list.
Enlist diffrent types of inheritance supported by java?
What is bytecode verifier?
What is runtime polymorphism or dynamic method dispatch?
Name the method that used to clear the buffer ?
Can we pass null as argument in java?
Is it possible to write static method in abstract class? justyfy your answer?
What is the difference between a checked and an unchecked exception?
What is the different between get and post?
can rmi and corba based applications interact ?