Question: This is java, I got a question, when I store byteX into shortX then I display shortX, I get -128. Even though shortX have more

This is java,

I got a question, when I store byteX into shortX then I display shortX, I get -128. Even though shortX have more bits than byteX, why it is not 128,

I got the same problem, I tried also to have byteX to be equal to 20000 , but when I stored it in shortX. I got a completely different answer (32), why it is not 128?

This is java, I got a question, when I store byteX into

shortX then I display shortX, I get -128. Even though shortX have

+ 0 BOutline X 4 # practice Practice S main Practice.java X X .classpath Labclass.java 2 3 public class Practice { 50 public static void main(String[] args) , 6 7 8 9 byte bytex; 10 bytex = (byte)128; //bytex has 0111 1111; 11 short shortX; 12 shortX = byteX; // shortx has 13 // 0000 0000 0111 1111 14 int intX; 15 intX = byteX; 16 long longX; 17 longX = intX; 18 float floatX; 19 floatx = intX; 20 double doubleX; 21 doubleX = intX; 22 System.out.println(shortx); 23 24 25 } 26 27 } 28 Problems @ Javadoc Declaration Console X Practice [Java Application] C:\Users ony1\Downloads\eclipse-java-2020-12-R-win32-x86_64\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full. - 128 Labclass.java Practice.java X X .classpath 2 3 public class Practice { BOutline X 6192 # practice 2. Practice main(String[]) public static void main(String[] args) { 50 6 7 9 byte bytex; 10 bytex = (byte)20000; //bytex has 0111 1111; 11 short shortX; 12 shortX = byteX; // short has 13 // 0000 0000 0111 1111 14 int intX; 15 intx = bytex; 16 long longX; 17 longx = intX; 18 float floatX; 19 floatx = intX; 2220 double doubleX; 21 doubleX = intX; 22 System.out.println(shortx); 23 24 25 } 26 27 } 28 A Problems @ Javadoc Declaration & Console X | x | = b 2 = 1 g E

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!