Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
Can we cast an int value into byte variable? what will happen if the value of int is larger than byte?
Home
JAVA
Can we cast an int value into byte variable? what will happen if the value of int is larger than...
+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.
Your comment on this answer:
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Related questions
0
votes
Q: What is variable in java?
asked
Oct 11, 2020
in
JAVA
by
SakshiSharma
#variable-in-java
#java-variable
Java-questions-answers
+1
vote
Q: What will this return 3*0.1 == 0.3? true or false?
asked
Jan 24, 2020
in
JAVA
by
rahuljain1
#java-variable
Java-questions-answers
0
votes
Q: What are the Variables in Java
asked
Mar 29, 2020
in
JAVA
by
rajeshsharma
#java-variable
#variable-java
Java-questions-answers
+1
vote
Q: Difference between a = a + b and a += b ?
asked
Jan 24, 2020
in
JAVA
by
rahuljain1
#java-variable
Java-questions-answers
0
votes
Q: What is the default value of byte variable?
asked
May 18, 2020
in
JAVA
by
AdilsonLima
#java
Java-questions-answers
0
votes
Q: What is the default value of int variable?
asked
May 18, 2020
in
JAVA
by
AdilsonLima
#java
Java-questions-answers
+3
votes
Q: In a class implementing an interface, can we change the value of any variable defined in the interface in Java?
asked
May 31, 2020
in
JAVA
by
SakshiSharma
#java-class-implementation
#java-class-interface
#class-interface-java
Java-questions-answers
0
votes
Q: As we know that the Decr command in Memcached is used to decrease the numeric value of an existing key, what will happen if the key is not numeric?
asked
Jul 29, 2023
in
MemCached
by
sharadyadav1986
decrcommandmemcached
0
votes
Q: If I don't provide any arguments on the command line, then what will the value stored in the String array passed into the main() method, empty or NULL?
asked
Nov 14, 2020
in
JAVA
by
rajeshsharma
#java-null
Java-questions-answers
+1
vote
Q: What is the size of an int variable in 32-bit and 64-bit JVM?
asked
Jan 24, 2020
in
JAVA
by
rahuljain1
#jvm-size
Java-questions-answers
...