KnowledgeBoat Logo

Output Questions for Class 10 ICSE Computer Applications

Give the output of the following:


int a[] ={2,4,6,8,10};
a[0]=23;
a[3]=a[1];
int c= a[0]+a[1];
System.out.println("Sum = "+c);

Java

Java Arrays

ICSE

92 Likes

Answer

Sum = 27

Working

a[0]=23 assigns 23 to the first element of the array. a[3]=a[1] assigns the value of second element of the array which is 4 to the fourth element of the array. After the execution of these two statements array looks like this:
{23, 4, 6, 4, 10}
a[0]+a[1] ⇒ 23 + 4 ⇒ 27

Answered By

50 Likes