Which code fragment, when inserted at line 3, enables t…

Given the code fragment:

Which code fragment, when inserted at line 3, enables the code to print 10:20?

Given the code fragment:

Which code fragment, when inserted at line 3, enables the code to print 10:20?

A.
int[] array n= new int[2];

B.
int[] array;
array = int[2];

C.
int array = new int[2];

D.
int array [2] ;



Leave a Reply 5

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


cho

cho

B.
int[] array;
array = new int[2];
C.
int[] array = new int[2];

twin

twin

A and B. C is not an array

renko

renko

Answer: A (if int[]array = new int[2]; thus without n)
package q090;

public class Test {

public static void main(String[] args) {
/* insert code*/

int[] array = new int[2]; // without n

//int[] array;
//array = int[2];

//int array = new int[2];

//int array[2];

array[0] = 10;
array[1] = 20;
System.out.print(array[0] +” “+ array[1]);
}
}
/*Output:
10 20
*/

Suckmibaby

Suckmibaby

There is a typo in the given answers. I did the exam and passed, this question also came and the right answer is c: int[] array = new int[2];

renko

renko

If answer C is: int[] array = new int[2];, then C is the correct answer.
Thank you.