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

How to compare strings in java?

0 Answers  


What is the difference between method and constructor ?

3 Answers  


Why is java not 100% pure oops?

0 Answers  


Can a class be defined inside an interface?

0 Answers  


Is nullpointerexception checked or unchecked?

0 Answers  






Explain the difference between abstract classes and interfaces in java?

0 Answers  


How to do validation of the fields in any project ?

2 Answers  


Can we write method inside a method in java?

0 Answers  


How can a gui component handle its own events?

0 Answers  


How java uses the string and stringbuffer classes?

0 Answers  


What is the purpose of the wait(), notify(), and notifyall() methods in java programming?

0 Answers  


What do you understand by looping in java? Explain the different types of loops.

0 Answers  


Categories