Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  Can a == true && a == false be true in JavaScript?

JavaScript is a weak typed language and it has a loose comparison feature where two objects/values of different type can be compared using == operator. This provides developers great flexibility and confusion at the same time. Before understanding how == works in JavaScript, can you first answer the question in the post title? Can a == true && a == false be true in JavaScript? Normally, we would think that this expression will always return false since a can be either true or false but cannot be both. However, in JavaScript, the above expression can return true indeed.If we h...

19,318 2       == JAVASCRIPT INTERVIEW QUESTION COMPARISON


  What will the value of Integer.valueOf(127) == Integer.valueOf(127) be in Java?

Do you really understand how Java does the integer comparison? OK, ignore the statements in the post title. What we are interested in is another set of comparison statements. Let's first see below code snippet.public class IntegerComparison { public static void main(String[] args) { Integer a = 127, b = 127; Integer c = 128, d = 128; System.out.println(a == b); System.out.println(c == d); }}What do you think the output will be? Are they both displaying true? You will find out the answer after reading through how Java optimizes some of the integer comparison logic.First, you need to un...

11,022 3       JAVA == EQUALSTO