What is the result?

Given:

1. public class Venus {
2. public static void main(String[] args) {
3. int[] x = { 1, 2, 3 };
4. int y[] = { 4, 5, 6 };
5. new Venus().go(x, y);
6. }
7.
8. void go(int[]… z) {
9. for (int[] a : z)
10. System.out.print(a[0]);
11. }
12. }

What is the result?

Given:

1. public class Venus {
2. public static void main(String[] args) {
3. int[] x = { 1, 2, 3 };
4. int y[] = { 4, 5, 6 };
5. new Venus().go(x, y);
6. }
7.
8. void go(int[]… z) {
9. for (int[] a : z)
10. System.out.print(a[0]);
11. }
12. }

What is the result?

A.
1

B.
12

C.
14

D.
123

E.
Compilation fails.

F.
An exception is thrown at runtime.

Explanation:



Leave a Reply 1

Your email address will not be published. Required fields are marked *