Professional Documents
Culture Documents
Roll No:-
2301146 FYMCA
Div. A
1. Write a Java program to test if an array contains a specific
int flag=0;
if (i == target) {
flag++;
if (flag==0){
}else{
System.out.println(target+" is present");
containsValue(array,7);
containsValue(array,13);
}
}
2. Write a Java program to insert an element (specific position) into an array.
import java.util.Arrays;
int position = 2;
int[newLength];
newArray[i] = array[i];
newArray[position] = element;
newArray[i + 1] = array[i];
return newArray;
}
}
3. Write a Java program to find the maximum and minimum value of an array.
max = arr[i];
min = arr[i];
}
4. Write a Java program to compare two strings lexicographically.
if (result1 < 0) {
} else {
if (result2 < 0) {
} else {
}
5. Write a Java program to concatenate a given string to the end of another string.
import java.util.*;
return s+s1;
String firstString=s.nextLine();
String secondString=s.nextLine();