Adobe Interview Question for Software Engineer / Developers






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

please explain a bit more, your question is not clear

- Anonymous May 04, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What is expected as an answer, possible reasons for the crash?

- Erik May 04, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

you could write something like this:
Note: this version is platform dependent, diff. pltfrms implement stacks differently
int sum(int a,int b){
int c;
int *ptr = &a;
ptr--;ptr--;
*ptr = 0x034322; //Over write the return address
return c;
}

main(){
cout<<"sum = "<<sum(1,2)<<endl;
}

- Anonymous May 05, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The ans is a fun. which doesn't do anything wrong but still crashes the program?

- Anonymous May 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!cpp
int func()
{
  int arr[1];
  arr[1] = 0; // marking the returnn addr as 0
  return 0;
}
int main()
{
   func();
   return 0;
}

- Ashutosh May 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think what they are asking for, is what could be a possible bug.

The most common occurence of a bug such as this, is when one overflows a statically declared buffer, thereby corrupting the stack frame, possibly borking the return address.

- Anonymous May 12, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

May be the function is returning Illegal address.

- Arulmozhi July 05, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Anonymous & Murugan
Quite possible! might be what the interviewer was expecting? right@Sun
otherwise the question is incomplete/dumb..

- googler August 19, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I cannot understand either of the codes gives up (@Anon and @ashu). Either explain clearly or do not give a solution at all!

- jai ho August 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Keep return type as int& lol

- Hello October 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Question is very clear. Asking for possible (and infact most commonly opted wrong progrmming style) bug that can result into crash.

Solution.
int * sum(int a,int b){

// Initialize a local pointer.
int *ptr = &(a +b);
return ptr;
}

main(){
cout<<"sum = "<<*(sum(1,2))<<endl;
}
//here in main when trying to access pointer that is local to sum function and is already died as soon as control came out from sum, it may cause crash. (plateform dependent)

- Y. Kanetkar December 09, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I have a serious doubt.How can u use &(a+b) to initialize pointer p. You should use an extra variable c=a+b and then use int *p=&c;
But the solution seems correct otherwise because the local pointer has already run our of scope and the pointer returned is definite to make the programme crash :)

- Coder :P September 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

cout<<"sum = "<<*(sum(1,2))<<endl;
why this line will not print 3 as output. but if we assign it to other pointer variable and then print its value it will print the value as 3. Could u explain ?
Although the program will crash at some time... but still could u explain the above reason. It prints 0...

- Anonymous March 20, 2012 | 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