Page 70 - CTS - CSA TP - Volume 2
P. 70
COMPUTER SOFTWARE APPLICATION - CITS
// intValue()
int intResult = byteValue.intValue();
System.out.println(“intValue(): “ + intResult);
// longValue()
long longResult = byteValue.longValue();
System.out.println(“longValue(): “ + longResult);
// floatValue()
float floatWResult = byteValue.floatValue();
System.out.println(“floatValue(): “ + floatResult);
// doubleValue()
double doubleResult = byteValue.doubleValue();
System.out.println(“doubleValue(): “ + doubleResult);
}
}
Output :
2 Short
• Represents a 16-bit signed integer.
• Methods include: shortValue(), intValue(), longValue(), floatValue(), doubleValue().
Task_Short : Here’s an example program demonstrating the use of methods inherited from the Number
class for the Short class:
public class ShortMethodsExample {
public static void main(String[] args) {
// Example using Short class
Short shortValue = 300;
// byteValue()
byte byteResult = shortValue.byteValue();
System.out.println(“byteValue(): “ + byteResult);
55
CITS : IT & ITES - Computer Software Application - Exercise 90