Amazon Interview Question for Software Engineer / Developers






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

compostion is a OOP concept:

it works similar funcionality to inheritance but creates a different relationship. Compostion a "has-a" relationship - versus the inhertiance of "is-a" relationship

compostion - the way you model objects that contain other objects. In OOP- you use instance variables of one object to hold references to other objects.

in java- for compostion - you instance the object in another object(dependence injection)

public class SportsCar{
//....
}

public class Ferrari{
  private SportsCar newCar = new SprotsCar();

}

In java- inheritance is created through the extends - example Ferrari extends SportCar.

{{public class SportsCar{
private int engineSize;

public void add(int size){

}
public void remove(){
}
}

public Ferrari extends SportCar{
private SportsCar newCar;

}

}

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

While I agree the sum-up is correct, what I do not agree is the example.

Car Object must have an Engine. So Car is composed of Engine. That is a composition.
en.wikipedia.org/wiki/Object_composition

- becga March 11, 2010 | 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