Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

You probably meant 'equals':
The latter (i.e. '==') is used to compare references:
Example:
String str = new String("foo");
if (str == "foo") // This would never return true, because '==' will compare the references (memory locations) and not the content.
Therefore, we use str.equals("foo") // it compares content of the object.

- Gagan September 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

equals is little ambiguous when it comes to StringBuffer.. see the example
public static void main(String[] args) {
String s = new String("hello");
String s2 = s;
System.out.println("1>" + s.equals("hello") + " 2>" + s.equals(s2)
+ " 3>" + (s == s2) + " 4>" + (s == "hello"));
StringBuffer sb = new StringBuffer("hello");
StringBuffer sb2 = sb;
System.out.println("1>" + sb.equals("hello") + " 2>" + sb.equals(sb2)
+ " 3>" + (sb == sb2));
}

o/p:: 1>true 2>true 3>true 4>false
1>false 2>true 3>true

- kn January 17, 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