Home » Java » Post Increment with substitution

Post Increment with substitution

Posted by: admin October 21, 2018 Leave a comment

Questions:

I have a question here already of my own but I want to extend it Post increment with example

char a = 'D';
int b = 5;
System.out.println(a++/b+--a*b++);

As one of the answers for the question is:

(68 / 5) + (68 * 5) and b++ doesnt have the effect on this .

My doubt is if b++ doesnt have effect then why a++ is having the effect?
Ideally it should have been

Step 1: (68/b+--a*b++);

Now a = 69;

Step 2: (68/b+--a*5)

Now a = 69;
b =6;

Step 3: (68/b+68*5)

Step 4: (68/6+68*5)

Answer which 351 but the answer epected is 353

Answers: