how to swap to variables without using thrid variable in java?
Answers were Sorted based on User's Feedback
Answer / igor polivanyi
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 ? | 8 Yes | 0 No |
Answer / hemant verma
a=a^b^(b=a);
Hemant Verma
FameofLight@gmail.com
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
what is opps?why it is use in programming language?
What are constructors in oop?
what is the realstic modeling?
write a c++ program to find maximum of two numbers using inline functions.
What language is oop?
Difference between vector and array
How do you achieve polymorphism?
What is function overloading?,describe it with the example.
Why polymorphism is used in oops?
what is the difference between javap and jad utility
difference between abstraction and encapsulation with progarammatic eg. hi,just recently i went for an interview .The interviewer asked what is the difference between abstraction and encapsulation with programmatic eg. I gave the answer as encapsulation mean hiding the relevant data which is not useful for the user, eg a electric fan .hiding the information how the electricity is converted into machanical energy. abtraction showing only the relevant data to the user eg electric fan. it look ,its color ,it design etc only relevant data. Then the interviewer asked me, give me some programmic eg .I Said Let assume a web form having control like textbox,button etc. The user can view textbox,button etc this is the eg of abstraction and when the user click on the button how he is redirected is not known by the user is the eg of the encapsulation. Am I Correct .was the answer given by me is perfect .now i am planing to go for an another interview should i give the same answer.IF not please suggest me a better answer.with some good eg Please help
What is multilevel inheritance?