Santosh Ramakrishna

Greenhorn
+ Follow
since Feb 09, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Santosh Ramakrishna

<pre>

public class Boxing6 {

public static void main(String[] args) {

Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean(true);
boolean b3 = true;
Boolean b4 = true;
System.out.println(b1==b2);
System.out.println(b1==b3);
System.out.println(b3 == b4);
System.out.println(b1 == b4);
}
}

</pre>

What is the output for the above program?
1)false true true false
2)false false false false
3)true true true true
4)false false true true

1 is the answer. I have a fairly good understanding of autoboxing and using the object from the pool.

if b1 and b4 are not equal, they are pointing to different objects, which is fine. How b1 == b3 and b3 == b4 both return true?

Thanks for your help.