Goldman Sachs Interview Question for Software Engineer / Developers


Country: United States




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

1. All objects are subclasses of java.lang.Object.

2. Reflexive, symmetric, transitive, consistent, and type aware, as mentioned above by Prince
are important attributes of an equals function. The equals method is closely related to the hashCode method in that they both speak about the identity of the object in question. If you override the equals method it is a good practice to override the hashCode method as well to ensure that two equal object return the same hashCode output.

3. The equals method should be implemented with the nature of the object in mind. An immutable object with hundreds of fields can have an optimized equals method which involves the object creating a hash-based id of itself upon initialization and comparing that value between two target objects when the equals method is invoked. For increasingly write-heavy objects a similar approach can be taken where hashes are generated for the more stable set of fields to optimize the average cost of comparison.

- enzeart August 15, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Best practise are

1. reflexive for non null reference value x, x.equals(x) should be true
2. Symmetic for non null refrence values x and y. x.equals(y) should return true iff y.equals(x) returns true
3. transitive for non null reference values x,y and Z if x.equals(y) and y.equals(z) then x.equals(z) should return true
4. Consistent i.e. x.equals(y) should always return true irrespective of the number of call made
5. For any non null reference x x.equals(null) should return false.

How about calling hashcode on two object and if they return same value then its equals else they are not.

- Prince August 13, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

about the equals method, you want to copy one object into another, just create a copy constructor. might take some time but easy and modifiable according to need.

- ayush August 17, 2014 | Flag Reply


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