Open In App

UGC-NET | UGC NET CS 2017 Jan – III | Question 38

Given the array of integers ‘array’ shown below :
13, 7, 27, 2, 18, 33, 9, 11, 22, 8.
What is the output of the following JAVA statements ?

int [ ] p = new int [10];
int [ ] q = new int [10];
for (int k = 0; k 

(A) 20 : 20
(B) 18 : 18
(C) 18 : 20
(D) 20 : 18

Answer: (C)
Explanation:

int [ ] p = new int [10];
int [ ] q = new int [10];
for (int k = 0; k 

In for (int k = 0; k
We are copying array element in array after that p[4] = 20; will make final change into p array.
So, array[4] is same as previous(i.e. 18) but p[4] is now 20.
So, option (C) is correct.
Quiz of this Question

Article Tags :