Question: What will be the result of compiling and running the following program? Select the one correct answer. (a) The program does not compile because of

What will be the result of compiling and running the following program?

public class RQ800A20 { static void compute (int... ia) { System.out.print(""); for

Select the one correct answer.

(a) The program does not compile because of errors in one or more calls to the compute() method.

(b) The program compiles, but throws a NullPointerException when run.

(c) The program compiles and prints:
|10|11|
|12|13|14|
|15|16|
|19|
|20|
|21|
|22|

(d) The program compiles and prints:
|12|13|14|
|15|16|
|10|11|
|19|
|20|
|21|
|22|

public class RQ800A20 { static void compute (int... ia) { System.out.print(""); for (int i : ia) { System.out.print (i+"|"); System.out.println(); } } static void compute (int[] ial, int... ia2) { compute (ial); compute (ia2); } } static void compute (int[] ial, int[]... ia2d) { for (int[] ia : ia2d) { compute (ia); } } } public static void main(String[] args) { compute (new int[] {10, 11), new int[] {12, 13, 14}); compute (15, 16); compute (new int[] {17, 18), new int[] [] {{19}, {20}}); compute (null, new int[] [] {{21}, {22}}); // (1) // (2) // (3) // (4) // (5) // (6) // (7)

Step by Step Solution

3.35 Rating (170 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

c The calls to the compute method in the method declarations at 2 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming 8th Questions!