Paper9 (Arrays)
Paper9 (Arrays)
Ques 4 What will be the output of following code? int ar[ ] = { 2, 5, 8, 9, 1, 6, 4, 9, 3,5 };
System.out.println( ar [3] * 2 );
System.out.println( ar[ 4 ] + 3 );
System.out.println( ar[ 6+2 ] * 3 );
Ques5 What will be the output of following code? int ar[ ]={ 2,5, 8, 9, 1, 6, 4, 9, 3, 5 };
i) State the start and end indices of ar[ ].
(ii) State the element at 3rd and 7th index.
(iii) Find and print the middle index and the element present.
Ques6
i) Intiallize an array with your 5 friends name.
ii) To declare single subscripted variable of 14 real numbers. initialize first 10 even
integers in a single
iii) Intiallize an array with vowels.
iv) Intiallize an array with no. of days in each month.
v) Declare a two dimensional integer array m of 3 rows and 3 columns.
System.out.println (p);
Ques 12 State the total size in bytes, of the array a[ 4 ] of char data type and p[ 4 ] of float
data type.
Ques 13 Write statement to find the length of a character array named ch.
Ques 14 If int[] n ={1, 2, 3, 5, 7, 9, 13, 16); what are the values of x and y?
x= Math.pow( n[ 4 ], n[ 2 ]);
y= Math.sqrt( n[ 5 ] + n[ 7 ] );
ques 15 Find errors in the given program code an statements correctly to assign values to
an integer array.
int a= new int (5);
for( int i = 0; i <= 5; i++)
a[i] = i;
ques 16
If int x[ ] = { 4, 3, 7, 8, 9, 10 ); what are the values of p and q?
(i) p = x. length
(ii) q = x[ 2] + x[ 5]* x[1];
(i) System.out.println( m[ 1 ][ 1 ]* 10 );
(ii) System.out.println( m. length );
(iii) System.out.println( m[ 1 ]. length );
(iv) System.out.print(m[0][2] + '+ m[1][2]);
28. Assume the array A[[ ] = {{1, 2, 3}, {4, 5, 6),{7, 8, 9}};