Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

1) MyObject foo;
foo object of type is created on stack (memory of size sizeof(MyObject) is allocated on stack.
2) MyObject *bar;
pointer of type MyObject class is created which is pointing to some unknown location.
3) MyObject *foobar = new MyObject();
memory is allocated on heap.

- techcoder November 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

First one is just an object of MyObject named foo.
Second one is a pointer to the object of MyObject.
Third one creates an object of MyObject and points the variable to that object.

- Anonymous November 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I would like add correction
1. it is local object, with run-time limited by {} or program life-time.
2. uninitialized pointer to object of type MyObject.
3. initialized with address of dynamicly created object.

- Anonymous November 24, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 4 vote

Easy One :-

1> Object foo of class type MyObject is being created on the stack.
2> Pointer named bar is being created which can point to the object of the type MyObject.
3> Here object of the class MyObject is being created on the heap.

- hprem991 November 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1.object will create as a local variable
2. pointer of object will create as a local variable
3.pointer of object will create as a local variable and it is pointing to object which is created in heap.

- manish kumar August 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

only first one is correct.....
because object itself is a reference variable....
and moreover java doesn't support pointer(*)

- ramesh December 19, 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