which one is more efficient
int x;
1. if(x==null)
2.if(null==x)
state which one either 1 or 2?

Answers were Sorted based on User's Feedback



which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?..

Answer / sudhanshu

1. if (x==null)
is the correct answer.

Is This Answer Correct ?    21 Yes 8 No

which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?..

Answer / sandeep

x is a int,a primitive. it can never be null

Is This Answer Correct ?    9 Yes 3 No

which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?..

Answer / person

neither... they wouldn't compile without explicit Integer cast.

Is This Answer Correct ?    2 Yes 0 No

which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?..

Answer / priyanka

2. if(null==x) is correct

Is This Answer Correct ?    3 Yes 3 No

which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?..

Answer / kishore

1.if (x==null) is correct answer.

Is This Answer Correct ?    5 Yes 6 No

which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?..

Answer / santosh

if the value is null how can we compare it always (x==null)correct

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More Core Java Interview Questions

Which method will get invoked first in a stand alone application?

1 Answers  


What is data type in java?

0 Answers  


Explain final, finalize() and finally?

11 Answers   Accenture, TCS,


What is Servlet?

8 Answers  


Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?

0 Answers  


What do you mean by ternary operator in java?

0 Answers  


what is the diff between Servletcontext and servletconfig?

5 Answers  


Write a program to find the greatest of three numbers in java?

0 Answers  


What is hashing principle in java?

0 Answers  


What do you understand by final value?

0 Answers  


How many types of gc are there in java?

0 Answers  


What is ide with example?

0 Answers  


Categories