Ques1
String s1 = "phoenix"; String s2 ="island";
System.out.println(s1.substring(0).concat(s2.substring(2)));
System.out.println(s2.toUpperCase());
Ques2 Given that d[ ] = (4, 5, 6, 1, 2, 3); What will be the values of d[0+2] and d[2-2]?
Ques3 Consider an array mx[] declared and initialized with float type elements. Write a valid
java statement to show that, how many elements are in the array?
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.
Ques7 Give the output
int y[]= {2,4, 5, 8};
int q = y.length; int p=0;
for(int j = 0; j<q; j++)
p = y[j]+y[ 3-jl:
System.out.println (p);
Ques8 Give the output of the following code:
int ar[ ] = (3, 4, 5 , 6);
for(int j = 0; j < 4; j++)
{
for(int n = 0; n <=j; n++)
System.out.print(ar[ n ]+ " ");
System.out.print("\n");
}
Ques 9 Give the output of the following code:
int z[] = (39, 42, 36, 45, 75, 98);
System.out.print(z[ 3]+","+ z[ 4]* 2):
Ques 10 What will be the values stored in variable a & b after the given statements get
executed ?
Int arr[]={6,4,8,5,9};
Int a=(arr[2] + arr[1]);
Int b=(arr[3+1] +20);
Ques 11 Given that int x[ ][]= {{2,4, 6}, (3, 5, 7}}; what will be the value of x[1][0] and x[0][2] ?
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];
Ques 17 Perform the following operations:
Assume the array m[[ ] = {{3, 5, 1}, {5, 6, 7}}; Give the output of the following statements:
(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}};
Give the output of the following statements:
(i) System.out.println( A[ 2 1 ]* A[ 1 ][ 2]);
(ii) System.out.println( A. length + 1);
(iii) System.out.println(A[2].length + A[0].length);
(iv) System.out.println( A[2-1][1*2] );
Q 29 WAP to find min and max from 20 input nos.
Q 30 WAP to search an element using linear search.
Q31 WAP to sort string array in descending order using bubble sort
Q32 WAP input name and population of n countries. Print the name of country having
maximum and minimum population.
Q33 WAP to store 6 elements in an array P and 4 elements in array Q and produce a third
array R containing all the elements of P and Q. Display the resultant array.
Q 34 WAP to input 2 arrays of size 10. Check whether they are identical or not.