ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
how to swap to variables without using thrid variable in java?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to swap to variables without using thrid variable in java?
Answer
# 1
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 ?    1 Yes 0 No
Mani
 
  Re: how to swap to variables without using thrid variable in java?
Answer
# 2
It’s pretty simple:

	int a = 12;
	int b = 34;

	a = a + b;
	b = a - b;
	a = a - b;

And for real cowboys, it could be simplified further:

	a -= (b = (a += b) - b);
 
Is This Answer Correct ?    1 Yes 0 No
Igor Polivanyi
 
 
 
  Re: how to swap to variables without using thrid variable in java?
Answer
# 3
a=a^b^(b=a);

Hemant Verma
FameofLight@gmail.com
 
Is This Answer Correct ?    1 Yes 0 No
Hemant Verma
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
Does c++ support multilevel and multiple inheritance? Wipro5
What is the Advantage of Interface over the Inheritance in OOPS?  2
Which is the only operator in C++ which can be overloaded but NOT inherited?  3
Please tell me the oops concept with detailed answer EEE4
What do you mean by pure virtual functions?  4
features of OOPS Ness-Technologies5
What normal C constructs work differently in C++?  1
Why do we use virtual functions?  3
how to find no of instances of an object in .NET? Infosys1
what is the difference b/w abstract and interface? Merrill-Lynch1
What is the difference between pass by reference and pass by value? TCS6
What is an orthogonal base class?  1
what is diff between .net 1.1 and .net 2.0  3
Can we call a base class method without creating instance?  4
what is the difference between <stdio.h>and "stdio.h"?  2
what is the basic concept of inheritance?  4
What is the correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass  4
What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 2) 17 3) 16.5 TCS10
What are virtual functions?  2
what is difference b/w object based and object oriented programming language? Infosys2
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com