I recently took a quiz and I was hoping someone could explain the correct answer to me. I have researched the question but still believe my answer was correct.

The question is:

The Test class is given below. Assume that ann and sue are variables of this Test class, where y is a static variable but x is not.. What number is printed by the sequence of 3 statements ann.think(); sue.think(); ann.print(); right after ann and sue are initialized?

I had chosen 36 as the answer. The quiz states the answer is 42. Can anybody please explain why? Thank you so much!

Now, try the math again.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson

*Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.*— Junilu

[How to Ask Questions] [How to Answer Questions]

`x`-- so when Ann's

`x`changes, Sue's

`x`doesn't, and vice versa. Since

`y`is static, it means that there's only one of it shared between the entire population of Test instances, which in this case is just Ann and Sue. So when Ann changes

`y`, Sue "sees" that change, and vice versa.

Think of x as a secret that Ann and Sue keep to themselves. It's like they picked a card from a deck and they each have their own card. If Ann folds her card in half, that doesn't affect Sue's card. And if Ann picks another card from the deck, Sue's card (her

`x`) doesn't change. Same thing works the other way around, if Sue changed her card, Ann's card doesn't change.

`y`on the other hand is a card that the teacher is holding up so both Sue and Ann can see it. If the teacher changes the card she holds up, both Ann and Sue see the same card.

Now, given that, go back and show us how you think those values change again.

*Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.*— Junilu

[How to Ask Questions] [How to Answer Questions]

*Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.*— Junilu

[How to Ask Questions] [How to Answer Questions]

Practice mindfully by doing the right things and doing things right.

[How to Ask Questions] [How to Answer Questions]

Practice mindfully by doing the right things and doing things right.

[How to Ask Questions] [How to Answer Questions]