Login
Remember
Register
Ask a Question
Can we cast an int value into byte variable? what will happen if the value of int is larger than byte?
+1
vote
asked
Jan 24, 2020
in
JAVA
by
rahuljain1
Can we cast an int value into byte variable? what will happen if the value of int is larger than byte?
#java-variable
Java-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jan 24, 2020
by
SakshiSharma
Yes, we can cast but int is 32 bit long in java while byte is 8 bit long in java so when you cast an int to byte higher 24 bits are lost and a byte can only hold a value from -128 to 128.
...