how to swap to variables without using thrid variable in java?

Answer Posted / mani

int x = 15;
int y = 20;
System.out.println(x+" "+y);
x ^= y;
y ^= x;
x ^= y;
System.out.println(x+" "+y);

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is abstract class in oop?

615


What do you mean by Encapsulation?

726


Why do we use oop?

690


What is the benefit of oop?

647


What is meant by oops concept?

685






What is difference between data abstraction and encapsulation?

705


Can you inherit a private class?

732


Can a destructor be called directly?

689


Which method cannot be overridden?

661


What is the renewal class?

2258


What is basic concept of oop?

786


What are the features of oop?

733


What is inheritance in oop?

682


What is the difference between static polymorphism and dynamic polymorphism?

719


What is polymorphism and example?

665