Menu
Topics Index
...
`

Copy information


If you need explanation Read this topic

If you need Answer Take test on this topic

Copy information
What will be the output of the following program?
public class Copy {
    public static void main(String[] args) {
        int input[] = {23, 26, 52, 36, 75};
        byte copy[] = new byte[6];
        System.arraycopy(input, 0, copy, 0, input.length);
        for (byte element : copy) {
            System.out.print(element + " ");
        }
    }
}

A. 23 26 52 36 75 0
B. 23 26 52 36 75
C. Compilation Error
D. Runtime Error
Topic: System Class arraycopy() Method In Java

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. bcz  ArraystoreException araises.

Posted by Shabaaz Shaikz    2014-09-01 03:45:07


D

Posted by Ram Sai Kumar    2014-09-01 03:47:48


D:system.arrraycopy stored a native method...and array store exception araise

Posted by Ashok Reddi    2014-09-01 03:55:43


ans D, the ArrayStoreException will raise because the type mismatched, it is not possible to convert int to byte.

Posted by Damu Surya    2014-09-01 04:09:28


Damodar You  possible to convert int to byte...........in java

Posted by Arul Palanisamy    2014-09-01 04:20:14


Damodar You byte can take only 8 bits with the 8th bit for sign(+ or -)
241 = 11110001
2's complement of 1110001 is 1111 which is 15.

Posted by Arul Palanisamy    2014-09-01 04:26:55


Ans is D ... it throws an exception !

Posted by Akshay Bansod    2014-09-01 04:36:58


D ,, can't convert int to byte without casting ,,

Posted by Raju VarshnEy    2014-09-01 07:40:28


d.

Posted by Shubham Bansal    2014-09-01 07:44:55


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

Posted by Merit Campus    2014-09-02 05:11:48


© meritcampus 2019

All Rights Reserved.

Open In App