Amazon Interview Question for Software Engineer / Developers






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

moreover in data segment , static variables are stored for each function differently , so if there are multiple function delaring the same static variable , then in data segment , they are stored for each funciton differently .
u can see the dump by using nm command .

- tom September 07, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the static variable is stored in "static area"?

- Jackie September 08, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static variables are stored in BSS segment. BSS - Block started by Symbol. It exists in the lower part of data segment and the variables stored here are initialized to ZERO. So, if you declare as static int i; then i is stored in BSS segment.

If two functions say

function1 () {
static int i;
...
}

function2 () {
static int i;
...
}

it will not be stored in the BSS as two integer i's simply. Every variable will be mapped and stored with the function name and the variable name in the symbol table by the compiler. So, int i of function1 will be stored something like - f1:i (depends on compiler). So there wont be any conflict even if the same variable name is declared in multiple functions.

- Metallicatony September 10, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

NAME MANGLING .

- Anonymous July 27, 2009 | 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