AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: sprihak — October 6, 2006
    +37 votes
      + -

    Y = 12 and X = 6
    Why? because X will be incremented after y = Y+X has been carried out and result has been assigned to Y.

  2. Submitted By: Mohit — October 6, 2006
    +5 votes
      + -

    Yes Y = 12 and X = 6
    if it would have been y+=++x then the value of y would have been equal to 13 and x = 6
    I am sure about this
    Mohit

  3. Submitted By: Sridhar — October 10, 2006
    +6 votes
      + -

    It will expand as
    y = y + x++ ;
    = 7+5
    =12
    Y will be 12 and x will be 6.

    This is bcoz the Associativity of ++ is from Left to Right. So value of x is returned to + and later incremented. Hence the result.

  4. Submitted By: subrahmanyam — October 13, 2006
    -14 votes
      + -

    12
    y=y+x++
    y=5+7stored
    so
    12answer
    x value display 7 but memory stored 8

  5. Submitted By: Ravi kumar — November 9, 2006
    +4 votes
      + -

    y+=x++;
    y=y+(x++);
    x++ is postincrement so
    y=7+5=12
    After this expression x value will increment because of postincrement.
    So x =6.

  6. Submitted By: ashwini — November 28, 2006
    +6 votes
      + -

    y=y+x++
    here the addition of x and y is performed first and then x is incremented by one
    so y=7+5=12
    and then x=6

  7. Submitted By: xyz — December 13, 2006
    +1 votes
      + -

    Correct answer :

    Y = 12 and X = 6

  8. Submitted By: someone — August 2, 2007
    +0 votes
      + -

    here in the expression y+=x++; we have two operators, post-fix ‘++’ and ‘+=’ increment & assign.

    From the precedenc table, ++ has higher precedenc to += hence evaluated first.

    Hence,

    after executing y+=x++ we will have x=6 and y=13

  9. Submitted By: someone — August 2, 2007
    +1 votes
      + -

    when i tried i=i++ with i = 0, even after execution of this statement, value of i is still 0.

    The key to this is to understand the difference between the value of the expression and the value of the variable.

    what this does is…

    1) Get the current value of i. The value of the postfix increment expression is the value of the variable before the new value is stored. So we have to get the “before it’s incremented” value. This is the value of the expression i++.

    2) Increment i. This doesn’t alter the value of the expression that was obtained in step 1.

    3) Take the value of the expression that was retrieved in step 1 (the value of i before being incremented) and stuff it into i.

    in our example… y+=x++… x is incremented before the assignment but as it is post fix notation value of ‘x++’ will evaluate to 5 for any consideration in the expression, otherwise actual value of x is already 6!!!

    hence y+=x++ with initial value of y=7 and x=5 will have y=12 and x=6 after its execution.

  10. Submitted By: zahid — February 7, 2008
    not yet rated
      + -

    y=12 and x=6
    because y+=x++ means y=y+x.
    here y=7 & x=5(will not change)
    so y=7+5=12
    &
    x=6(increase after )

  11. Submitted By: Anjali — February 17, 2008
    not yet rated
      + -

    x=6 & y=12 post increment

  12. Submitted By: Medanki — March 6, 2008
    not yet rated
      + -

    In statements like y+=x++, the evalauiton looks like below.

    1. it is post increment so the value of x is first assigned to y and then incremented. y+=5, y=y+5
    at last y is 12

    2. x++ is incremented now, x=6

  13. Submitted By: chetan kakkar — October 1, 2008
    not yet rated
      + -

    x=6
    y=12

  14. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.