Question

4. Consider the following declarations ; char c = ‘a’; byte b = 1; short s...

4. Consider the following declarations ;

char c = ‘a’;

byte b = 1;

short s = 2;

int i = 3; long l = 4;

float f = 5.0f;

double d = 6.0;

Indicate the value which is assigned to the LHS of the assignment statement in each of the following.

a. i = b + 2 * s / 2 + i;

b. i = (b + 2 * s) / (2 + i);

c. i += (b + 2 * s) / 2 + i;

d. i += (b + 2 * s) / 2.0 + i;

e. c = (char)(c + 1);

f. i += b++ + ++i;

g. i = ++b * s++;

h. i = – – i + i – –;

0 0
Add a comment Improve this question Transcribed image text
Answer #1
a. i = b + 2 * s / 2 + i;
i = 6

b. i = (b + 2 * s) / (2 + i);
i = 0

c. i += (b + 2 * s) / 2 + i;
i = 2

d. i += (b + 2 * s) / 2.0 + i;
i = 6

e. c = (char)(c + 1);
c = b

f. i += b++ + ++i;
i = 14

g. i = ++b * s++;
i = 6

h. i = – – i + i – –;
i = 10
Add a comment
Know the answer?
Add Answer to:
4. Consider the following declarations ; char c = ‘a’; byte b = 1; short s...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT