Overstock.com Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 1 vote

== compares the object reference while equals compares value of object.
ex.

String one=new String("home");
		String two=new String("home");
		
		if(one.equals(two))
			System.out.println("equal");
		else
			System.out.println("not equal");

here output will be "equal" but if we use == then answer will be not equal.

- Anonymous December 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The difference between "==" and the "equals" method is that "==" always compares the object reference and is true when they are the same object. The "equals" method on the other hand will also compare the object references only if the "equals" method has not been over ridden.

- cwa December 01, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

'==' checks only content ..... but equals can check both on the basis of address and content.
but by default equals check on the basis of address....we can write our own logic for content checking by over-riding with following signature
public boolean equals(Object)
{
return.......;
}

- prasun.pallav18 February 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

== operator is used to compare two object reference values....but 'equals operator is used to compare two contents which is stored in objects.
eg:
String s1=new String("welcome");
String s2=new String("welcome");
if(s1==s2)
{
System.out.println("two strings are equal");
}
else
{
System.out.println("two strings are not equal");
}

in above example we are using '=='operator so,it gives output is "two strings are not equal".

inplace of '=='operator we are using 'equals'
if(s1.equals(s2))
then it give output as "two strings are equal"

- deepa February 26, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

== operator is used to compare two object reference values....but 'equals operator is used to compare two contents which is stored in objects.
eg:
String s1=new String("welcome");
String s2=new String("welcome");
if(s1==s2)
{
System.out.println("two strings are equal");
}
else
{
System.out.println("two strings are not equal");
}

in above example we are using '=='operator so,it gives output is "two strings are not equal".

inplace of '=='operator we are using 'equals'
if(s1.equals(s2))
then it give output as "two strings are equal"

- deepa February 26, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

== operator is used to compare two object reference values....but 'equals operator is used to compare two contents which is stored in objects.
eg:
String s1=new String("welcome");
String s2=new String("welcome");
if(s1==s2)
{
System.out.println("two strings are equal");
}
else
{
System.out.println("two strings are not equal");
}

in above example we are using '=='operator so,it gives output is "two strings are not equal".

inplace of '=='operator we are using 'equals'
if(s1.equals(s2))
then it give output as "two strings are equal"

- deepa February 26, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

== means Reference equality where two or more reference variable points to same object

Equals means either two or more objects are meaningfully equivalent or not

- Nadim November 21, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More