Question 1: Java Coding Question:
Problem
:You are given a String array containing numeric strings. Your task is to reverse the strings at odd indices of the array, and then sum the reversed value with the string at the even index. After summing, if the length of the resulting string is greater than 5, you need to take the first 5 digits and store it in the corresponding index of a new output array.Requirements:1. Input: A String inputArray where each element is a numeric string.2. Processing:• For each string at odd index (1, 3, 5, etc.), reverse the string.For each even index (0, 2, 4, etc.), sum the original string at that index withthe reversed string at the odd index immediately following it.If the resulting sum exceeds 5 digits, take the first 5 digits of the sum.3. Output: The new String[] outputArray which contains the transformed values according to the rule above.Constraints:The input array contains only numeric strings.The array can be of any length, but the length will always be at least 2.
Input
: String inputArray("12345", "67890", "45678", "13579");
Output
: String[] outputArray("22221", "14320");
Question 6 : Java Coding Question
Problem:
Given a list of daily temperatures, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put
0
instead.
Input:
int[] temperatures = {73, 74, 75, 71, 69, 72, 76, 73};
Output:
int[] result = {1, 1, 4, 2, 1, 1, 0, 0};
Question 7 : Java Coding Question
Problem:
You are given a String array containing numeric strings. Your task is to perform the following operations:1. For strings at even indices (0, 2, 4, etc.), append the length of the string to itself.2. For strings at odd indices (1, 3, 5, etc.), prepend the length of the string to itself. If the resulting string exceeds 5 characters, take the first 5 characters and store them in the corresponding index of a new output array.
Input:
String[] inputArray = {"123", "4567", "890", "12345"};
Output:
String[] outputArray = {"1233", "44567", "8903", "51234"};
Question 8 : Java Coding Question
Problem:
Given a string and an array of indices, replace the characters of the string at given indices with a specified character.
Input:
String s = "hello";int[] indices = {1, 3};char replacement = '*';
Output:
String result = "h*l*o";
Question 9 : Java Coding Question
Problem:
Given two arrays of strings, interleave them to form a single array. If one array is longer than the other, append the remaining elements of the longer array at the end.
Input:
java
String[] arr1 = {"a", "b", "c"};String[] arr2 = {"1", "2", "3", "4"};
Output:
String[] result = {"a", "1", "b", "2", "c", "3", "4"};