+1 vote
in JAVA by
Can we cast an int value into byte variable? what will happen if the value of int is larger than byte?

1 Answer

0 votes
by
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.

Related questions

0 votes
asked May 18, 2020 in JAVA by AdilsonLima
+1 vote
asked Jan 24, 2020 in JAVA by rahuljain1
...