Category Archives: Java Programs

Java Interview Program #8

Problem Statement: Given two String inputs and one integer input. input 1: “abc2012345” input 2: “abc2112660” input 3: 4 Here “abc**” refers to the customer id and seven numeric digits after abc is the Electricity Bill reading. 12345 refers to the last month’s Electricity Bill reading and 12660 refers to this month’s Electricity Bill reading. Find the difference… Read More »

Java Interview Program #7

Problem Statement: Given one String input and two integer inputs. input 1: xyzwabcd input 2: 2 input 3: 4 Fetch the sub-string starting from input 2 till input 3 and print it in the reverse order. output: bawz Solution: Result: bawz

Java Interview Program #6

Problem Statement: Given two input Strings. input 1: “New York” input 2: “NWYR” Compare both the given strings, if the characters in input 1 are present in input 2 , then write the same character in output string else write ‘+’. output: N+w+Y+r+ Ignore the case difference. Solution: Result: N+w+Y+r+

Java Interview Program #5

Problem Statement: Given a input String. input 1: commitment c being the first index position. Remove the vowels which are at the even index of the string. output: cmmitmnt Solution: Result: cmmitmnt

Java Interview Program #4

Problem Statement: Given an arrayList of String type having  the format:- name#mark1#mark2#mark3 input 1: {“arun#12#12#12″,”deepak#13#12#12”} Retrieve the name of the student who has scored maximum marks. output: deepak Total marks will be the sum of matk1, mark2 and mark3 i.e. Total marks=mark1+mark2+mark3 Solution: Result:

Java Interview Program (3)

Problem Statement: Given two arrayLists of same length:- input 1: {12,1,32,3} input 2: {0,12,2,23} Retrieve the odd position elements form input 1 and even position elements from input 2. Put the retrieved elements into the new arrayList  say output at the same positions from where they are retrieved from. output: {0,1,2,3} Consider 0th position as even position. Solution: Result:

Java Interview Program (2)

Problem Statement: Given three strings say input 1, input 2 and input 3:- input 1: “GeniusRajkumarDev” input 2: “Raj” input 3: “Dev” Return 1 if input 2 comes before input 3 in input 1 else return 2 output: 1 Solution: Result:

Java Interview Program (1)

Problem Statement: Given two integer arrays, merge the common elements into a new array and find the sum of the elements. input 1: {1,2,3,4} input 2: {3,4,5,6} common elements: {3,4} output:7 Logic: Solution: Result: