Interview Question for Software Engineer / Developers






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

its in pop, you should first save the variable and then reduce the index and return it.

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

No thats wrong.
the index shows the index of the obj added in future.
So initially indx= 0 when there are no obj added.
While adding we 1st add the obj with the indx and then increase the indx. Similarly for pop we 1st decrease the indx and then return the obj of the indx

- Anshul Zunke February 16, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The code is in C++, so, there should be a ; after brace which ends class, and other thing is variables are cannot be initialized in class - use a constructor

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

private Object[] objects

I never saw this code in C++..

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

Doesn't look like c++ to me
1. no boundary checking in push() => can exceed maxCount
2. no boundaries checking in pop() => index can become negative
3. object[index]=null in pop() with saving the value into temp variable for garbage collection

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

1.)index shud be static
2.) both the methods shud be synchronized

- sauravmanit March 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

index cannot be static. Clearly, this represents a stack and obviously you cannot have one common index value (top pointer) across all stacks!!!!!

- kddev1109 May 13, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1.maxCount should be final static.
2.It should have some boundary check in push method to make sure the maxium number of object in the array is 1000.
3.In pop method it should add if(index>=1){}, otherwise index could be negative.

- Anonymous March 15, 2011 | 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