see , In first case :-
We are initializing a variable of type integer having value 101 ...
and we are printing ++a and a ...
++a means it is a preincrement operator and a++ is post-increment operator
working :-
consider a box of a having value 101 ...
++a means preincrement operator , increments value first and update in the box
and then print that value ( value into the box...)
and a++ means postincremement operator , it print the value in the box first and then increment the value in the box , and update that value in the box
same for decrement also
In case first :-
a=101
and we are printing the ++a and a ...
Now consider a box of a having value 101 ...
++a will increment the value first means it becomes 102 and update 102 value into the box of a ...
now , box of a contains 102
and then there is no operation ...
so box of a contains 102 ...
so it will print 102 , 102 as a output ...
In case 2:-
a=101
and we are printing ++a , a , a--
so consider a box of a contains value 101 ....
in that case , if there is more than two operators , then bracket will be solve first
(++a,(a,a--))
first operation is a , the value in the box a will remains same ...
now , value into the box a will be 101 means remains same
next operation is a-- , it will be decrement the value into the box a to 100 ..and update the value in the box
now value in the box a will be 100
next operation is ++a , so it will be increment the value into the box of a ..
first
now value into the box a will be 101 .... again
and it will print 101 , 101 , 101 as output ....
ill not starting java ... that as ill not give you ans of java ...