1. class SumofArray { public static void main(String[] args) { int[]arr=new int[]{1,2,3,4}; int len=arr.length; int sum=0; for(int i=0;i<arr.length;i++){ sum=sum+arr[i]; } System.out.println("Sum of all element:"+sum); } } 2. class Array { public static void main(String[] args) { int arr[]={1,2,12,5}; int len=arr.length; for(int i=0;i<len;i++) { System.out.println(arr[i]); } System.out.println("After modification:"); for(int i=0;i<len;i++) { System.out.println(arr[i]+1); } } } 3. class EvenSum{ public static void main(String[] args) { int arr[]={1,2,12,5}; int evenSum=0; for (int i = 0; i < arr.length; i++) { if (arr[i] % 2 == 0) evenSum=evenSum+arr[i]; } System.out.println("Sum of even number:"+evenSum); } } 4. class EvenOddSum{ public static void main(String[] args) { file:///C/Users/dell/Documents/hC1.txt[27-12-2023 14:28:40] int arr[]={12,1,5,8,4,7}; int evenSum=0; int oddSum=0; for (int i = 0; i < arr.length; i++) { if (arr[i] % 2 == 0) evenSum=evenSum+arr[i]; else oddSum=oddSum+arr[i]; } System.out.println("Sum of all even number:"+evenSum); System.out.println("Sum of all odd number:"+oddSum); } } file:///C/Users/dell/Documents/hC1.txt[27-12-2023 14:28:40]