Top 70 Java Program Interview Questions: Here, we will list down all the Java Programs.
Solutions Will Be Added Soon
1. Write a Program For the Below Output
Input: [Rama, Test, Type, Tata]
Expected: RTTTaeyamsptatea
Input: [Rama, Test, Type, Tata]
Expected: RTTTaeyamsptatea
2. Write a Program For the Below Output
Input: today110is210my310interview
Output: yadot110si210ym310weivretni
Input: today110is210my310interview
Output: yadot110si210ym310weivretni
3. Write a Program For the Below Output
Input: lekhale
Output: 2
Input: lekhale
Output: 2
4. Write a Program For the Below Output
Input: dadeadrs
Output: dddaaers
Input: dadeadrs
Output: dddaaers
5. Write a Program For the Below Output
6. Write a Program For the Below Output
Input: Welcome to Mis2is2ip2i Bla4k Adam
Output:Welcome to Mississippi Blaaaak Adam
Input: Welcome to Mis2is2ip2i Bla4k Adam
Output:Welcome to Mississippi Blaaaak Adam
7. Write a Program For the Below Output
Input: abbcccdeee
Output: a1b2c3d1e3
Input: abbcccdeee
Output: a1b2c3d1e3
8. Write a Program For the Below Output
Input: Today is January 5th
Output: 5thJa nu aryisTo day
Input: Today is January 5th
Output: 5thJa nu aryisTo day
9. Write a Program For the Below Output
Input: 1234
Output: [1234, 11223344, 111222333444, 1111222233334444]
Input: 1234
Output: [1234, 11223344, 111222333444, 1111222233334444]
10. Write a Program For the Below Output
Input: [A, B, C, D]
Output: AA BB CC DD
Input: [A, B, C, D]
Output: AA BB CC DD
11. Write a Program For the Below Output
Input: AAAADDDCCCA
Output: A4D3C3A1
Input: AAAADDDCCCA
Output: A4D3C3A1
12. Write a Program For the Below Output
Input: tomorrow
Output: t#m##rr###w
Input: tomorrow
Output: t#m##rr###w
13. Write a Program For the Below Output
Input: [1, 2, 2, 3, 4, 5, 5, 3]
Output: 1,3,4,3,
Input: [1, 2, 2, 3, 4, 5, 5, 3]
Output: 1,3,4,3,
14. Write a Program For the Below Output
Input: Selenium
Output:
eleniumS
leniumeS
eniumleS
niumeleS
iumneleS
umineleS
muineleS
Input: Selenium
Output:
eleniumS
leniumeS
eniumleS
niumeleS
iumneleS
umineleS
muineleS
15. Write a Program For the Below Output
Input: 1230
Output: 03210
Input: 1230
Output: 03210
16. Write a Program For the Below Output
Input: he is a good boy
Output: yo bd o ogas ieh
Input: he is a good boy
Output: yo bd o ogas ieh
17. Write a Program For the Below Output
Input: AcBCbDEdea
Output: AaBbCcDdEe
Input: AcBCbDEdea
Output: AaBbCcDdEe
18. Write a Program For the Below Output
Input: 11001101011
Output: 11111110000
Input: 11001101011
Output: 11111110000
19. Write a Program For the Below Output
Input: AAAABBCCCDDDDEEEG
Output: A4B2C3D4E3G1
Input: AAAABBCCCDDDDEEEG
Output: A4B2C3D4E3G1
20. Write a Program For the Below Output
Input: 1B3A2D4C
Output: BAAADDCCCC
Input: 1B3A2D4C
Output: BAAADDCCCC
21. Write a Program For the Below Output
Input:[5, 0, 4, 6, 0, 7, 0]
Output: 0 0 0 5 4 6 7
Input:[5, 0, 4, 6, 0, 7, 0]
Output: 0 0 0 5 4 6 7
22. Write a Program For the Below Output
Input: 01IND02AUS03ENG
Output: {“01″:”IND”,”02″:”AUS”,”03″:”ENG”}
Input: 01IND02AUS03ENG
Output: {“01″:”IND”,”02″:”AUS”,”03″:”ENG”}
23. Write a Program For the Below Output
input : [3,R,M,4,89,f]
OutPut: [3,4,89,M,R,f]
input : [3,R,M,4,89,f]
OutPut: [3,4,89,M,R,f]
24. Write a Program For the Below Output
25. Write a Program For the Below Output
Input ( 1,2,3,4,5 )
Output- { 3,4,5,1,2 }
Input ( 1,2,3,4,5 )
Output- { 3,4,5,1,2 }
26. Write a Program For the Below Output
Input: [looking, you, handsome, are]
Output: [you, are, looking, handsome]
Input: [looking, you, handsome, are]
Output: [you, are, looking, handsome]
27. Write a Program For the Below Output
Input: reverse me without split
Output: esrever em tuohtiw tilps
Input: reverse me without split
Output: esrever em tuohtiw tilps
28. Write a Program For the Below Output
Input: My n@me is 12Rahul
Output: yM em@n si 12luhaR
Input: My n@me is 12Rahul
Output: yM em@n si 12luhaR
29. Write a Program For the Below Output
Input – Hi I am Naveen I need and answer
Output – answer and deen I Naveen ma I Hi
Input – Hi I am Naveen I need and answer
Output – answer and deen I Naveen ma I Hi
30. Write a Program For the Below Output
Input: Hello world,welcome to my world,my world
Output: world Hello ,world my to welcome ,world my
Input: Hello world,welcome to my world,my world
Output: world Hello ,world my to welcome ,world my
31. Write a Program For the Below Output
Inout: amZgxY
Output: x
Inout: amZgxY
Output: x
32. Write a Program For the Below Output
Input: GDP in 2016 has fallen from 6.8% to 4.5%
Output: GDP in 6102 has fallen from 8.6% to 5.4%
Input: GDP in 2016 has fallen from 6.8% to 4.5%
Output: GDP in 6102 has fallen from 8.6% to 5.4%
33. Write a Program For the Below Output
Input: [1, 2, 3, 4, 5]
Output: 21435
Input: [1, 2, 3, 4, 5]
Output: 21435
34. Write a Program For the Below Output
Input: [2, 1, 1, 4, 5, 5, 6, 7]
Output: [2, 4, 6, 7]
Input: [2, 1, 1, 4, 5, 5, 6, 7]
Output: [2, 4, 6, 7]
35. Write a Program For the Below Output
Input: Ramakant
Output: R1a1m1a2k1a3n1t1
Input: Ramakant
Output: R1a1m1a2k1a3n1t1
36. Write a Program For the Below Output
Input: [()]{}{[()()]()}
Output: Balanced
Input: [()]{}{[()()]()}
Output: Balanced
37. Write a Program For the Below Output
38. Write a Program For the Below Output
Input = AAABBBBCC
Output = A3B4C2
Input = AAABBBBCC
Output = A3B4C2
39. Write a Program For the Below Output
Input: weelccoommee hhoommeee
Output: welcome home
Input: weelccoommee hhoommeee
Output: welcome home
40. Write a Program For the Below Output
Input: Aut@oma#tion@#
Output: Aut@oma#tion..
Input: Aut@oma#tion@#
Output: Aut@oma#tion..
41. Write a Program For the Below Output
Input: AB2C99423A
Output: A2B9C9A4
Input: AB2C99423A
Output: A2B9C9A4
42. Write a Program For the Below Output
Input: “abCdefGHijkl”
Output:”ab Cdef G Hijkl”
Input: “abCdefGHijkl”
Output:”ab Cdef G Hijkl”
43. Write a Program For the Below Output
Input: abc
Output: abc,acb,bac,bca,cba,cab,
Input: abc
Output: abc,acb,bac,bca,cba,cab,
44. Write a Program For the Below Output
Input: HELLO WORLD
Output: HExxxO WORxxxD
Input: HELLO WORLD
Output: HExxxO WORxxxD
45. Write a Program For the Below Output
Input: INDIA
Output: INDIIA
Input: INDIA
Output: INDIIA
46. Write a Program For the Below Output
Input: Welcome[21], Java1How are you78
Sum of numbers : 100
Sum of digits of numbers : 19
Input: Welcome[21], Java1How are you78
Sum of numbers : 100
Sum of digits of numbers : 19
47. Write a Program For the Below Output
Input=”1222bbbbcccaaaammmmm”
Output=”1222cccbbbbaaaammmmm”
Input=”1222bbbbcccaaaammmmm”
Output=”1222cccbbbbaaaammmmm”
48. Write a Program For the Below Output
Input: test986java656hello
Output: tset986avaj656olleh
Input: test986java656hello
Output: tset986avaj656olleh
49. Write a Program For the Below Output
Input: minimum
Output: n–1
Input: minimum
Output: n–1
50. Write a Program For the Below Output
Input: 1234567890
Output: (123)45-67-890
Output: (123)45-67-890
Input: 1234567890
Output: (123)45-67-890
Output: (123)45-67-890
51. Write a Program For the Below Output
Input: tomorrow
Output: ooorrtmw
Input: tomorrow
Output: ooorrtmw
52. Write a Program For the Below Output
Input: [Hi, maven, selenium, java]
Output: [Hi, java, maven, selenium]
Input: [Hi, maven, selenium, java]
Output: [Hi, java, maven, selenium]
53. Write a Program For the Below Output
Input: 38: Output: 2
Input: 1485631: Output: 1
Input: 0: Output: 0
Input: 38: Output: 2
Input: 1485631: Output: 1
Input: 0: Output: 0
54. Write a Program For the Below Output
Input: egg , add
Output: true
Input: egg , add
Output: true
55. Write a Program For the Below Output
Input: [1, 2, 3, 4, 9, 5, 6, 7, 8, 10, 0]
The Combinations in the array whose sum is 10 are:
(1,9)
(2,8)
(3,7)
(4,6)
(0,10)
Input: [1, 2, 3, 4, 9, 5, 6, 7, 8, 10, 0]
The Combinations in the array whose sum is 10 are:
(1,9)
(2,8)
(3,7)
(4,6)
(0,10)
56. Write a Program For the Below Output
Input: Automation Testing
Output: aUTOMATION tESTING
Input: Automation Testing
Output: aUTOMATION tESTING
57. Write a Program For the Below Output
Input: Monojjonon
Character occurrence in a string- {j=2, M=1, n=3, o=4}
Min Value : 1 Max Value : 4
Ascending order values – {M=1, j=2, n=3, o=4}
Input: Monojjonon
Character occurrence in a string- {j=2, M=1, n=3, o=4}
Min Value : 1 Max Value : 4
Ascending order values – {M=1, j=2, n=3, o=4}
58. Write a Program For the Below Output
59. Write a Program For the Below Output
Input:123456
Output: 654321
Input:123456
Output: 654321
60. Write a Program For the Below Output
Enter a number: 1235
Input: 1235
Output: The input number is odd
Enter a number: 1235
Input: 1235
Output: The input number is odd
61. Write a Program For the Below Output
Input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Even numbers: 2 4 6 8 10
Total Number of Even Numbers in this Array = 5
Odd numbers: 1 3 5 7 9 11
Total Number of Odd Numbers in this Array = 6
Input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Even numbers: 2 4 6 8 10
Total Number of Even Numbers in this Array = 5
Odd numbers: 1 3 5 7 9 11
Total Number of Odd Numbers in this Array = 6
62. Write a Program For the Below Output
Enter a Number: 123456
Input: 123456
Output: Not a palindrome number
Enter a Number: 123456
Input: 123456
Output: Not a palindrome number
63. Write a Program For the Below Output
64. Write a Program For the Below Output
65. Write a Program For the Below Output
66. Write a Program For the Below Output
67. Write a Program For the Below Output
68. Write a Program For the Below Output
Input: !I a#m S@ou$%^ra@v
Output: I am Sourav!#@$%@
Input: !I a#m S@ou$%^ra@v
Output: I am Sourav!#@$%@
69. Write a Program For the Below Output
70. Write a Program For the Below Output
Input: [1, 5, 9, 1, 4, 9, 6, 5, 9, 7]
Output: 1 5 9 4 6 7
Input: [1, 5, 9, 1, 4, 9, 6, 5, 9, 7]
Output: 1 5 9 4 6 7
71. Write a Program For the Below Output
Input: Welcome to Softwar Testing Blog
Output: Blog Testing Softwar to Welcome
Input: Welcome to Softwar Testing Blog
Output: Blog Testing Softwar to Welcome
72. Write a Program For the Below Output
Input: [99, 2, 55, 6, 88, -1]
Small No: -1 Big No: 99
Input: [99, 2, 55, 6, 88, -1]
Small No: -1 Big No: 99
73. Write a Program For the Below Output
74. Write a Program For the Below Output
Input: this interview is for CBA
Output: is for CBA this interview
Input: this interview is for CBA
Output: is for CBA this interview
75. Write a Program For the Below Output
Input: Mono1j2
Output: 12
Input: Mono1j2
Output: 12
76. Write a Program For the Below Output
Input: %i a#m m@o$noj346
Number of digits (Output): 3
Input: %i a#m m@o$noj346
Number of digits (Output): 3
77. Write a Program For the Below Output
78. Write a Program For the Below Output
79. Write a Program For the Below Output
Input: SoftwareTestingo
Output: ognitseTerawtfoS
Input: SoftwareTestingo
Output: ognitseTerawtfoS
80. Write a Program For the Below Output
Input: A: 1, B: 2
Output: A: 2, B: 1
Input: A: 1, B: 2
Output: A: 2, B: 1
81. Write a Program For the Below Output
Input: softwaretestingo
Output: fwaring
Input: softwaretestingo
Output: fwaring
82. Write a Program For the Below Output
Input: [17, 24, 6, 3, 39, 1]
Enter the value of k : 2
2 largest array element From Array is 24
Input: [17, 24, 6, 3, 39, 1]
Enter the value of k : 2
2 largest array element From Array is 24
83. Write a Program For the Below Output
Input: [12, 3, 5, 7, 19]
Enter The Kth Element: 3
K’th smallest element is 7
Input: [12, 3, 5, 7, 19]
Enter The Kth Element: 3
K’th smallest element is 7
84. Write a Program For the Below Output
Input: [10, 21, 22, 100, 101, 200, 300]
Total number of triangles possible is: 6
Input: [10, 21, 22, 100, 101, 200, 300]
Total number of triangles possible is: 6
85. Write a Program For the Below Output
Enter the String: SoftwareTestingo
Enter The K Value: 2
After Removing The Characters Having More then 2 Times:- SfwarTsing
Enter the String: SoftwareTestingo
Enter The K Value: 2
After Removing The Characters Having More then 2 Times:- SfwarTsing
86. Write a Program For the Below Output
Enter the Value of N to Find Prime Numbers Between 1 to N: 8
Prime Numbers Between 1 to 8 are: 2 3 5 7
Enter the Value of N to Find Prime Numbers Between 1 to N: 8
Prime Numbers Between 1 to 8 are: 2 3 5 7
87. Write a Program For the Below Output
Input: abcdcbe
Longest palindrome substring is: bcdcb
Length is: 5
Input: abcdcbe
Longest palindrome substring is: bcdcb
Length is: 5
88. Write a Program For the Below Output
89. Write a Program For the Below Output
90. Write a Program For the Below Output
Input: Welcome to Java Session Session Session
Output:
Welcome–1
to–1
Java–1
Session–3
Input: Welcome to Java Session Session Session
Output:
Welcome–1
to–1
Java–1
Session–3
91. Write a Program To Find the duplicate Word in a Text File?
92. Write a Program For the Below Output
Enter any String to remove numbers: Software2024Testingo
String after removing all numbers: SoftwareTestingo
Enter any String to remove numbers: Software2024Testingo
String after removing all numbers: SoftwareTestingo
93. Write a Program For the Below Output
Enter the string: software test ing o
Original String: software test ing o
Final String: softwaretestingo
Enter the string: software test ing o
Original String: software test ing o
Final String: softwaretestingo
94. Write a Program For the Below Output
Enter the string: softwaretestingo
Enter the Character you want to search: a
a is present at index 5
Enter the string: softwaretestingo
Enter the Character you want to search: a
a is present at index 5
95. Write a Program For the Below Output
Enter the string: Softwaretestingo
The First Repeated Character: t
Enter the string: Softwaretestingo
The First Repeated Character: t
96. Write a Program For reverse a string without using inbuilt functions?
Enter the string: Software Testingo
Before Reverse the String: Software Testingo
After Reverse the String: ognitseT erawtfoS
Enter the string: Software Testingo
Before Reverse the String: Software Testingo
After Reverse the String: ognitseT erawtfoS
97. Write a Program to print the frequency of words in a paragraph?
Enter the string: Wel Come to Our Blog
Blog – 1
Come – 1
Our – 1
Wel – 1
to – 1you – 2
your – 1
Enter the string: Wel Come to Our Blog
Blog – 1
Come – 1
Our – 1
Wel – 1
to – 1you – 2
your – 1
98. Write a Program For the Below Output
Suppose this is interger array (2,3,4,1,4,5) divide this array into from the index of that element where sum is equal for both divided arrays
Input: [2, 3, 4, 1, 4, 5]
Output: 1
Suppose this is interger array (2,3,4,1,4,5) divide this array into from the index of that element where sum is equal for both divided arrays
Input: [2, 3, 4, 1, 4, 5]
Output: 1
99. Write a Program For the Below Output
Input: abbcccddddcc
Output: Character: d, Count: 4
Input: abbcccddddcc
Output: Character: d, Count: 4
100. Write a Program For the Below Output
Input: Hello Interview Is Going On Now
Output: hello interview is going on now
Input: Hello Interview Is Going On Now
Output: hello interview is going on now
101. Write a Program For the Below Output
Input: [1, 2, 3, 4]
Output: 24 12 8 6
Input: [1, 2, 3, 4]
Output: 24 12 8 6
102. Write a Program For the Below Output
Input: softwaretestingo
Total no of vowels in string are: 6
Input: softwaretestingo
Total no of vowels in string are: 6
103. Write a Program For the Below Output
Enter a number: 1523
Reversed number: 3251
Enter a number: 1523
Reversed number: 3251
104. Write a Program For the Below Output
Input: 5450595638154862
After Masking Output: 545059******4862
Modified Output: 5450-59**-****-4862
Input: 5450595638154862
After Masking Output: 545059******4862
Modified Output: 5450-59**-****-4862
105. Write a Program For the Below Output
Enter the Name :Mukesh Kumar Sharma
Short Form: M.K.Sharma
Enter the Name :Mukesh Kumar Sharma
Short Form: M.K.Sharma
106. Write a Program For Remove the second highest element from the HashMap?
Input: {Thirty=30, Twenty=20, FourTwenty=420, one Twenty=120, Ten=10}
Output: {Ten=10, Twenty=20, Thirty=30, FourTwenty=420}
Input: {Thirty=30, Twenty=20, FourTwenty=420, one Twenty=120, Ten=10}
Output: {Ten=10, Twenty=20, Thirty=30, FourTwenty=420}
107. Write a Program to Print the Value Of a TreeSet or TreeMap?
108. Write a Program For the Below Output
Input: 1a b23cd e45f
Output: 69
Input: 1a b23cd e45f
Output: 69
109. Write a Program For the Below Output
Input: aBcA1bC2
Output: abcABC12
Input: aBcA1bC2
Output: abcABC12
110. Write a Program For the Below Output
List 1: [person1, person2, person3]
List 2: [person2, person5]
Values in list2 that are not present in list1:person5
List 1: [person1, person2, person3]
List 2: [person2, person5]
Values in list2 that are not present in list1:person5
111. Write a Program For the Below Output
Input: This ia a Sample String
Output: iiln
Input: This ia a Sample String
Output: iiln
112. Write a Program For the Below Output
Input Value: ab2c4d45ef234
Integers: 2,4,45,234
Characters: ab,c,d,ef
Input Value: ab2c4d45ef234
Integers: 2,4,45,234
Characters: ab,c,d,ef
113. Write a Program For the Below Output
Input: [2, 3, 5, 6]
Output: [6, 2, 5, 3]
Input: [2, 3, 5, 6]
Output: [6, 2, 5, 3]
114. Write a Program For the Below Output
First String: automation
Second String: automation
Final: [t, i, n]
First String: automation
Second String: automation
Final: [t, i, n]
115. Write a Program For the Below Output
Input: [1, 2, 3, 4, 5]
After Remove: 1 2 3 4
Input: [1, 2, 3, 4, 5]
After Remove: 1 2 3 4
116. Write a Program For the Below Output
Original String is: This is a String
First Character Occurance Character Is: T
Last Character Occurance Is: g
The Truncated String is: This is a String
Original String is: This is a String
First Character Occurance Character Is: T
Last Character Occurance Is: g
The Truncated String is: This is a String
117. Write a Program For the Below Output
Inpur: I am Rajesh, currently attending, interview with, abc systems
Output: Rajesh am I , attending currently , with interview , systems abc ,
Inpur: I am Rajesh, currently attending, interview with, abc systems
Output: Rajesh am I , attending currently , with interview , systems abc ,
118. Write a Program For the Below Output
Input: NewMumbai
Output: Mum
Input: NewMumbai
Output: Mum
119. Write a Program For the Below Output
Input String: aaabbbbcddeeeee
Second Most Frequent Character: bbbb
Input String: aaabbbbcddeeeee
Second Most Frequent Character: bbbb
120. Write a Program For the Below Output
Input: softwaretestingo
Char s 2 times
Char t 3 times
Char e 2 times
Char o 2 times
Input: softwaretestingo
Char s 2 times
Char t 3 times
Char e 2 times
Char o 2 times
121. Write a Program For the Below Output
Original String: abababababaabb
Sub String: bab
Total Number Of Substring Appears: 4
Original String: abababababaabb
Sub String: bab
Total Number Of Substring Appears: 4
122. Write a Program For the Below Output
Input: [7, 3, 4, 5, 5, 6, 2]
The repeating number is 5.
The missing number is 1.
Input: [7, 3, 4, 5, 5, 6, 2]
The repeating number is 5.
The missing number is 1.
123. Write a Program For the Below Output
Input Array 1: [1, 2, 3, 4, 5]
Input Array 2: [1, 2, 4, 5]
Missing number in array1 & array2 is: 3
Input Array 1: [1, 2, 3, 4, 5]
Input Array 2: [1, 2, 4, 5]
Missing number in array1 & array2 is: 3
124. Write a Program For the Below Output
125. Write a Program For the Below Output
Original String : softwaretestingo
After removing the duplicates : softwareing
Original String : softwaretestingo
After removing the duplicates : softwareing
a