Amazon Interview Question






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

I think answer should be tree. Question isnt clear though.
The whole concept of polymorphism in java runs around inheritance. If there is no inheritance then only maybe old kind of polymorphism like method overloading would be available.

- anonymous January 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Yes i answered inheritance , but he was quite... maybe expecting for more answer...

- akku January 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Interfaces?

- Anil January 25, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Inheritance, Interface, overloading(debatable) fundamental

- akku January 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How it helps: Circle,Square, Rectangle all inherit from class shape. Shape itself have an abstract method area() but does not implements it. Circle , Square, Rectangle will each implement its own version of it.
So When I make an Array that stores objects of type Shape and loop through it , calling array[i].area(), the area() mehtod of the appropraite obejct (square, rectangle,triangle, etc )will be called automatically. THis is polymorphism

- Anonymous January 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Well, you can achieve polymorphism in Java through both methods and classes, right? Is that what the interviewer meant by "basic structures"?

The concept of inheritance helping in polymorphism is simple. If you have a base class, then its subclass might override some of its methods.

Another way in which you can use polymorphism is to use a variable of the base class type to hold a reference to an instance of the derived class.

- Anonymous April 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

From Wikipedia: "feature that allows values of different data types to be handled using a uniform interface"

In my own words: ability to call different things the same name

In Java: Interface.

Sample: interface Paintable { void paint(); }

And not only Shapes, but also Cars, Dogs, Fruits, Artists...

Capability of an action/method to do different things depending on type of an object; also relates to method overloading / overriding

- bamba May 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In Java: Capability of an action/method to do different things depending on type of an object; also relates to method overloading / overriding

From Wikipedia: "feature that allows values of different data types to be handled using a uniform interface"

Sample: interface Paintable { void paint(); }

And not only Shapes, but also Cars, Dogs, Fruits, Artists... everyone/everything can paint :)

- bamba May 09, 2012 | 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