Menu
Topics Index
...
`

Byte Conversion2295


If you need explanation Read this topic

If you need Answer Take test on this topic

Byte Conversion2295
What will be the output of the following program?
public class ByteConversion {
    public static void main(String[] args) {
        Byte bt = new Byte("-129");
        byte b = bt.byteValue();
        String str = "Primitive byte value of Byte object: " + bt + " " + "is" + " " + b;
        System.out.print(str);
    }
}

A. Primitive byte value of Byte object: -129 is -129
B. Primitive byte value of Byte object: -129 is -127
C. Some other output
D. Compilation Error or Runtime Error
Topic: Creating Objects for Primitive Data Types (Byte, Short)

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

d.

bytevalue-This method returns the numeric value represented by this object after conversion to type byte.

java.lang.NumberFormatException: Value out of range. Value:"-129" Radix:10

Posted by Asma Mujtaba Khan    2014-09-08 04:05:31


ans is D ,, -129 is out of the range of byte,,, it is int,, int not change in byte without casting

Posted by Raju VarshnEy    2014-09-08 12:10:30


its D runtime error

Posted by Rohit Baranwal    2014-09-08 14:58:22


Congratulations Asma Khalil. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-09-09 04:15:47


© meritcampus 2019

All Rights Reserved.

Open In App