Computer Science, asked by adyashreeray10b2, 2 months ago

Output test : int a, b for( a=1 a<=5 a+=2)
{
for (b=1 b<=1 b++)
{
S1= S1+ (a+b)
S2=S2+(a*b)
}
}

Answers

Answered by yatharthsharma1118
0

Answer:

The program has a compile error because the size of the array wasn’t specified when declaring the array.

B. The program has a runtime error because the array elements are not initialized.

C. The program runs fine and displays x[0] is 0.

D. The program has a runtime error because the array element x[0] is not defined.

Explanation:

C

Explanation : Program is syntactically correct, so no error. In java, if the array is not initialized at the time of declaration and creation then all the elements of the array are initialized to 0 by default.

Ques2. What is the output of the following?

import java.util.*;

public class Test {

public static void main(String[] args)

{

int[] x = { 120, 200, 016 };

for (int i = 0; i < x.length; i++)

System.out.print(x[i] + " ");

}

}

Options :

A. 120 200 16

B. 120 200 14

C. 120 200 016

D. 016 is a compile error. It should be written as 16.

Similar questions