Discussion :: Objects and Collections - Pointing out the correct statements (Q.No.5)
|Abc said: (Jul 3, 2011)|
|I don't understand!|
|Akash Sharma said: (Nov 4, 2014)|
|Answer is not correct, lets see this example:
Here equals() method return true but hashcode() method return false.
public static void main(String args)
String b=new String ("akash");
|Devdyuti Singh` said: (Mar 31, 2016)|
|C is the right answer, because when == operator matches the object initiated in heap or string pool is locating the same address or nor.
If there are 2 instances are == operator will give true while equals method return false;
String s1=new String("Dev");
String s2=new String("Dev");
s1==s2 is false
s1.equals is true
Check it out.
|Rishabh Rastogi said: (Sep 23, 2017)|
|B is the right answer.|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.