🎴 Flashcard Mode
programming languages Online Quiz - 307
Card1 / 20
Mastered0
Review0
QuestionClick to flip
class B { public static void main (String args[]) { Double a = new Double(0xFFFF); byte b = a.byteValue(); short c = a.shortValue(); int e = a.intValue(); long f = a.longValue(); float g = a.floatValue(); double h = a.doubleValue(); System.out.print(b+","+c+","+ (e+f+g+h == 4 * 0xFFFF)); }} What is the result of attempting to compile and run the program?
AnswerClick to flip back
A
Prints: -1,-1,true
💡 Explanation:
Double(0xFFFF) creates a Double object with value 65535.0. When converted to byte or short, the value is -1 due to overflow. The sum of e+f+g+h equals 4*65535, so the expression evaluates to true. The output is -1,-1,true.