Menu
Topics Index
...
`

System Example


If you need explanation Read this topic

If you need Answer Take test on this topic

System Example
What will be the output of the following program?
public class SystemExample {
    public static void main(String[] args) {
        int a1[] = {0, 1, 2, 3};
        int a2[] = {1, 10, 20, 30};
        System.arraycopy(a1, 0, a2, 0, 2);
        System.out.print("a2 = ");
        System.out.print(a2[0] + " ");
        System.out.print(a2[1] + " ");
    }
}

A. a2 = 0 1
B. a2 = 1 10
C. a2 = 0 10
D. Compilation Error or 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.

ans is A,since arraycopy copies 2 elements from the a1 array(0th position) to the a2 array(0th postion).

Posted by Raviteja Daggupati    2014-03-25 03:51:01


ans : A
arraycopy(source,start pos ,destination ,start pos,length);
a1 is copied to a2 up  to two values
so out put is;
0 2

Posted by Ananda Kumar    2014-03-25 04:25:11


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

Posted by Merit Campus    2014-03-26 04:27:00


© meritcampus 2019

All Rights Reserved.

Open In App