Question: Hello everyone, This is java, why short shortX, print the number as -128 instead of 128 , byte prints it -128 because it can store

Hello everyone,

This is java,

why short shortX, print the number as -128 instead of 128 , byte prints it -128 because it can store only from -128-127, but short can store a much larger values than byte, why the result of shortX is -128 instead of 128?

Hello everyone, This is java, why short shortX, print the number as

7 8 9 //bytex has 0111 1111; 10 byte byteX = (byte) 128; 011 short shortX; 12 shortX= byteX; 13 14 System.out.println(bytex); 15 16 17 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 - 128

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!