Explain the working of the snippet | Sololearn: Learn to code for FREE!


Explain the working of the snippet

System.out.println((byte) (417)); It outputs -95. Explain the calculations

7/7/2020 5:52:05 AM

Ayush Pandey

7 Answers

New Answer


Ipang waiting for ur answer


Ayush Pandey You changed the Description. I suspect that happens because 417 is out of data range of 'byte' which is around -128 ~ 127. That might be an effect of value overflow, but I'm not sure I can explain. This article covers overflow effect of `int` type, but I suppose the same thing can happen with `byte`. https://dzone.com/articles/overflow-and-underflow-data


How does it evaluate to -95


Ayush Pandey That line does not even compile bro! Are you sure that is the complete code? or did you just write a portion of it?


Yeah I know you code man Don't get upset too quick though I didn't say you don't know the A's But that line, as it is, just trigger error That's all I'm saying ... lol


Danijel Ivanović May u explain me


Ipang lol.... what do you think I dont even know The "A's " of coding.... anyways actually I wrote in the title that it is snippet which actually means a portion of whole code.... So actually I want to know the working of this piece.... For I know how to write codes XD