Adobe Interview Question for Testing / Quality Assurances


Country: India
Interview Type: Written Test




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

Ans:
Q1: -2 3 01

Q2: -2 2 01

Q3: -2 3 1 1

- Hmmm January 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you please how this operation works?

- Rajiv January 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you please explain how this operation works?

- Ricky January 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you please explain how this operation/statement works?

- Ricky January 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Take Q2 as example:
int i=-3, j=2, k=0, m;
Step 1:
variable i, j, k, m are declared as an integer type and variable
i, j, k are initialized to -3, 2, 0 respectively.
Step 2:
m = ++i || ++j && ++k;
here (++j && ++k;) this code will not get executed because ++i has non-zero value.becomes
m = -2 || ++j && ++k; becomes m = TRUE || ++j && ++k;
The part (++j && ++k) will not be executed. Hence this statement becomes TRUE. So it returns '1'(one). Hencem=1.
Step 3:
printf("%d, %d, %d, %d\n", i, j, k, m);
In the previous step the value of variable 'i' only incremented by '1'(one). The variable j,k are not incremented.Hence the output is "-2, 2, 0, 1"

- BM January 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

wow damn smart

- kay May 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The explained way is not clear...

- Priyajay278 December 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

this is call Short-circuit evaluation.

- Anonymous February 13, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

suppose i write the code


int main()
{
int i=-1, j=2, k=0, m;
m = ++i && ++j || ++k;
printf ("%d %d %d %d", i,j,k,m);
return 0;
}

the output shows:
0 2 1 1
shouldnt it show
0 2 0 0
how does the operation takes place in this?

- anirban.datta.24 March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It is due to the precedence rules, since && and || have same precedence, the compiler is seeing it as (++i && ++j) || ++k. This of course puts into question all the results posted above.

- prkhr August 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

suppose i write the code


int main()
{
int i=-1, j=2, k=0, m;
m = ++i && ++j || ++k;
printf ("%d %d %d %d", i,j,k,m);
return 0;
}

the output shows:
0 2 1 1
shouldnt it show
0 2 0 0
how does the operation takes place in this?

- anirban.datta.24 March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It goes like
++i = 0 = FALSE
so FALSE && ++j || ++k
this will not evaluate ++j as whatever be the value of j this will be false
and will directly go and evaluate k

- Anonymous April 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

In C & in C++, the expression will only evaluated till we can't come across the answer from left to right.
For eg, in expr. c = a || b if a is true, then c will be true irrespective of b, so b will not be evaluated. but in expr. c = a && b, both needs to be evaluated.

All values (+ve or -ve) are treated as true expect ZERO.
and i think, u know about post/pre operator.

- Mridul Malpani April 12, 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