Java 400+ Practice Programs With Solutions

Java 400+ Practice Programs With Solutions


1 . Unary Minus Program
2 . PreIncrement Program
3 . PostIncrement Program
4 . PreDecrement Program
5 . PostDecrement Program
6 . Addition Program
7 . Substraction Program
8 . Multiplication Program
9 . Division Program
10 . Modular Division Program
11 . Swaping Of Two Numbers With Using Third Variable
12 . Swaping Of Two Numbers Without Using Third Variable
13 . Relation Of Two Numbers Program using > < <= >= !=
14 . Logical Operators Program using &&, || ,!
15 . Bitwise AND Program
16 . Bitwise OR Program
17 . Bitwise CAP Program
18 . Bitwise NEGATION Program
19 . Bitwise LEFT SHIFT Program
20 . Bitwise RIGHT SHIFT Program
21 . Odd or Even Number Using Ternary Operator
22 . Max Number Using Ternary Operator
23 . MAX Number Amoung 3 Numbers Using Ternary Operator
24 . ODD or Even Number Program Using IF ELSE Condition
25 . Max Number Program Using IF ELSE Condition
26 . Check the given number is valid or invalid(value must between 20 and 30)
27 . Check the given number is valid or invalid(value must divisible by 2 and 3)
28 . Check the given number is valid or invalid(value must divisible by 2 and 3 not 4) using if else
29 . Check the given character is vowel or consonant
30 . Check the given character is Small Letter or Not
31 . Check the given character is Capital Letter or Not
32 . Check the given character is Number or Not
33 . Check the given character is Symbol Letter or Not
34 . Simple Interest Program
35 . Check the given age is child or teen or younger or old or invalid or negetive using else if
36 . Max Number amoung the three numbers using else if
37 . Check the given character is vowel or consonant charater must be small
38 . Odd or Even number program using nested if condition value must be positive in java
39 . Odd or Even number using switch
40 . Vowel or Consonant using. switch
41 . Display 1 to 10 Values Using For Loop
42 . Display 10 to 1 Values Using For Loop
43 . Display 1 to N Values Using For Loop
44 . Display Even Numbers Using For Loop
45 . Display Even Number or Odd Number Based On The N Value Using For Loop
46 . Display Even Number or Odd Number Based On The N Value Using Single For Loop
47 . count the number of divisible numbers in a given range(1-100)
48 . count the number of divisible numbers in a given range(1-100) without using loop
49 . Factorial Number
50 . Factorial of N Numbers
51 . Sum Of Natural Numbers
52 . Sum Of Even Numbers
53 . Sum of Odd Numbers
54 . Sum Of Even Or Odd Numbers Based On The N value
55 . Sum Of Even Or Odd Numbers Based On The N value using single loop
56 . Display Table
57 . Display 1 to 10 Values Using while Loop
58 . Display 10 to 1 Values Using while Loop
59 . Display 1 to N Values Using while Loop
60 . Display Even Numbers Using while Loop
61 . Display Even Number or Odd Number Based On The N Value Using while Loop
62 . Display Even Number or Odd Number Based On The N Value Using Single while Loop
63 . Count the number of divisible numbers in a given range(1-100) using while loop
64 . Factorial Number Using While
65 . Factorial of N Numbers using while Loop
66 . Sum Of Natural Numbers using while Loop
67 . Sum Of Even Numbers using while Loop
68 . Sum of Odd Numbers using while Loop
69 . Sum Of Even Or Odd Numbers Based On The N value using while Loop
70 . Sum Of Even Or Odd Numbers Based On The N value using single while Loop
71 . for and while difference program(Factorial Number using while Loop (value must be positive number))
72 . for and while difference program(Vowel and consonant program (character must be small letter))
73 . Display 1 to 10 Values Using do while Loop
74 . Display 10 to 1 Values Using do while Loop
75 . Display 1 to N Values Using do while Loop
76 . Display Even Numbers Using do while Loop
77 . Display Even Number or Odd Number Based On The N Value Using do while Loop
78 . Display Even Number or Odd Number Based On The N Value Using Single do while Loop
79 . count the number of divisible numbers in a given range(1-100) Using do while Loop
80 . Factorial Number using do while Loop
81 . Factorial of N Numbers using do while Loop
82 . Sum Of Natural Numbers using do while Loop
83 . Sum Of Even Numbers using do while Loop
84 . Sum of Odd Numbers using do while Loop
85 . Sum Of Even Or Odd Numbers Based On The N value using do while Loop
86 . Sum Of Even Or Odd Numbers Based On The N value using single do while Loop
87 . Display Even Numbers Using Continue Statement
88 . Display Vowels Using Continue Statement
89 . Display the whose values divisible by 2 and 3 Continue Statement in java
90 . Break the loop which number is divisible by 2 and 3 in java
91 . Global and Local Variable Program
92 . MaxNumber Program Using No return type with No Parametarized method
93 . MaxNumber Program Using No return type with Parametarized method
94 . MaxNumber Program Using return type with No Parametarized method
95 . MaxNumber Program Using return type with Parametarized method
96 . Factorial Program Using No return type with No Parametarized method
97 . Factorial Program Using No return type with Parametarized method
98 . Factorial Program Using return type with No Parametarized method
99 . Factorial Program Using return type with Parametarized method
100 . Static variable Program
101 . Static Method Program
102 . Static block Program
103 . Single class 4 methods program
104 . 4 classes single method program
105 . Maxnumber program using No Parametarized Constructor with No return type with no Parametarized Method
106 . Maxnumber program using No Parametarized Constructor with No return type with Parametarized Method
107 . Maxnumber program using No Parametarized Constructor with return type with no Parametarized Method
108 . Maxnumber program using No Parametarized Constructor with return type with Parametarized Method
109 . Maxnumber program using Parametarized Constructor with No return type with no Parametarized Method
110 . Maxnumber program using Parametarized Constructor with No return type with Parametarized Method
111 . Maxnumber program using Parametarized Constructor with return type with no Parametarized Method
112 . Maxnumber program using Parametarized Constructor with return type with Parametarized Method
113 . Factorial program using No Parametarized Constructor with No return type with no Parametarized Method
114 . Factorial program using No Parametarized Constructor with No return type with Parametarized Method
115 . Factorial program using No Parametarized Constructor with return type with no Parametarized Method
116 . Factorial program using No Parametarized Constructor with return type with Parametarized Method
117 . Factorial program using Parametarized Constructor with No return type with no Parametarized Method
118 . Factorial program using Parametarized Constructor with No return type with Parametarized Method
119 . Factorial program using Parametarized Constructor with return type with no Parametarized Method
120 . Factorial program using Parametarized Constructor with return type with Parametarized Method
121 . this. Program
122 . without this( ) program
123 . with this( ) program
124 . Program for Student Details using Single Inhiritance concept
125 . Program for Student Details using multilevel Inhiritance concept
126 . Program for Student Details using Hirarchy Inhiritance concept
127 . Whthout abstract Program -1
128 . Whth abstract Program -2
129 . Creating object for abstract class -3
130 . Creating object for abstract class -4
131 . Creating object for abstract class -5
132 . Creating object for abstract class -6
133 . Creating object for abstract class -7
134 . Creating object for abstract class -8
135 . Down Casting Program-9
136 . Interface Program
137 . super. Program
138 . super() -NoParameterized
139 . super() -Parameterized
140 . PolyMorphism Program
141 . Method Overloading - Static PolyMorphism Program
142 . Method Overloading - Dynamic PolyMorphism Program
143 . Constructer Overloading Proogram
144 . Method Overridding - Static PolyMorphism Program
145 . Method Overridding Dynamic PolyMorphism Program
146 . Write a java program to illustrate innerclAccessing Inner Class Properties In Java
147 . Package Program
148 . Package Program using Encapsulation
149 . Package Program using DataAbstraction
150 . Package Program using Inheritance
151 . Package Program using PolyMorphism
152 . Write a program to handled the Arithmetic Exception
153 . Write a program to handle try with single catch block
154 . Write a program to handle try with Multiple catch blocks
155 . Write a java program to know above exception details using Exception class
156 . Write a java program to know above exception details using printStackTrace() Method
157 . Write a java program to know above exception details using getMessage Method
158 . Throws Keyword Program
159 . Finally block Program
160 . Write a program to handle negative age exception
161 . Write a program to handle negative salary exception
162 . Write a Simple interest program to handle negative amount and duration and interest using userdefined exception
163 . String Length Program
164 . String CharAt Program
165 . String Tolowercase Program
166 . String Touppercasse Program
167 . String StringConcat Program
168 . String Compreto Program
169 . String Compretoignorecase Program
170 . String Equals Program
171 . String Equalsignorecase Program
172 . String Startswith Program
173 . String Endswith Program
174 . String Indexof Program
175 . String Lastindexof Program
176 . String Substring Program
177 . String Trim Program
178 . StringBuffer Insert Program
179 . StringBuffer Delete Program
180 . StringBuffer Append Program
181 . StringBuffer Replace Program
182 . StringBuilder length Program
183 . StringBuilder CharAt Program
184 . StringBuilder Tolowercase Program
185 . StringBuilder Touppercasse Program
186 . StringBuilder Concat Program
187 . StringBuilder Compreto Program
188 . StringBuilder Compretoignorecase Program
189 . StringBuilder Equals Program
190 . StringBuilder Equalsignorecase Program
191 . StringBuilder StringBuilder Startswith Program
192 . StringBuilder Endswith Program
193 . StringBuilder Indexof Program
194 . StringBuilder Lastindexof Program
195 . StringBuilder Substring Program
196 . StringBuilder Trim Program
197 . StringBuilder Insert Program
198 . StringBuilder Delete Program
199 . StringBuilder Append Program
200 . StringBuilder Replace Program
201 . Count vowels in a given
202 . Count spaces in a given string
203 . Count Consonents in a given string
204 . Count number of special characters in a given string
205 . Remove vowels in a given string
206 . Remove Consonants in a given string
207 . Remove special characters in a given string
208 . Remove numbers in a given string
209 . How to print duplicate characters from the string?
210 . How to check if two strings are anagrams of each other?
211 . We can say if two strings are an anagram of each other if they contain the same characters but at different orders Example: army & mary
212 . How to reverse a string in Java without using the reverse method?
213 . How to count the occurrence of the given character in a string? String : Sateesh Character : e Count occurrence: 2
214 . How to check if a string is a palindrome?
215 . if the string is similar from the starting as well as the ending, then we can say that the string is a palindrome For example madam, radar, etc
216 . How to count the number of words in a given string sentence?
217 . How to reverse the words from the given string sentence? String: MSK Technologies OutPut: KSM seigolonhceT
218 . How to swap two strings without using the third variable? Before swapping The first String = one. The first String = two The second String = one ,The second String = two After swapping The first String = two The second String = one
219 . Write a java program to display message a 2sec time gap without using MultiThreading
220 . Write a java program to display message a 2sec time gap using Thread class
221 . Write a java program to display message a 2sec time gap using runnable interface
222 . Write a java program to display addition program and substraction program with 2 sec time gap
223 . Online reservation program without using Thread Synchronization
224 . Online reservation program with using synchronized method
225 . Online reservation program with using synchronized block
226 . One Dimensional Arrays Initilization Program
227 . One Dimensional Arrays Declaration Program
228 . One Dimensional Arrays Assignment Program
229 . Multi Dimensional Arrays Initilization Program
230 . Multi Dimensional Arrays Declaration Program
231 . Multi Dimensional Arrays Assignment Program
232 . Sum of Array Numbers
233 . Sum of Positive Number in Array
234 . count the number of negetive numbers in a arry
235 . Sum of Array Numbers (Array Values Must be positive)
236 . ArrayList Add() method program
237 . ArrayList Add() index method program
238 . ArrayList AddAll() method program
239 . ArrayList Clear() method program
240 . ArrayList Remove() method program
241 . ArrayList RemoveRange() method program
242 . ArrayList Contains() method program
243 . ArrayList Get() method program
244 . ArrayList IndexOf() method program
245 . ArrayList IsEmpty() method program
246 . ArrayList Set() method program
247 . ArrayList Size() method program
248 . ArrayList Toarray() method program
249 . ArrayList Clear() method program
250 . ArrayList Clone() method program
251 . Vector Add() method program
252 . Vector Add() method program
253 . Vector AddAll() method program
254 . Vector Clear() method program
255 . Vector Remove() method program
256 . Vector RemoveRange() method program
257 . Vector Contains() method program
258 . Vector Get() method program
259 . Vector IndexOf() method program
260 . Vector IsEmpty() method program
261 . Vector Set() method program
262 . Vector Size() method program
263 . Vector Toarray() method program
264 . Vector Clear() method program
265 . Vector Clone() method program
266 . Stack Empty() method program
267 . Stack Peek() method program
268 . Stack Push() method program
269 . Stack Pop() method program
270 . Stack Search() method program
271 . Stack RemoveRange() method program
272 . Stack Contains() method program
273 . LinkedList Add() method program
274 . LinkedList Addfirst() method program
275 . LinkedList Addlast() method program
276 . LinkedList GetFirst() method program
277 . LinkedList GetLast() method program
278 . LinkedList Get() method program
279 . LinkedList RemoveFirst() method program
280 . LinkedList Removelast() method program
281 . LinkedList Remove() method program
282 . LinkedList Clear() method program
283 . LinkedList Add(Index,Element) method program
284 . LinkedList RemoveFirst() method program
285 . Hashset Add() method program
286 . Hashset Remove() method program
287 . Hashset Clear() method program
288 . Hashset Size() method program
289 . Hashset Clone() method program
290 . Linked Hashset Add() method program
291 . Linked Hashset Remove() method program
292 . Linked Hashset Clear() method program
293 . Linked Hashset Size() method program
294 . Linked Hashset Clone() method program
295 . HashMap Put(Key,Value) method program
296 . HashMap Get() method program
297 . HashMap IsEmpty() method program
298 . HashMap Remove() method program
299 . HashMap Size() method program
300 . HashMap Keyset() method program
301 . HashMap Value() method program
302 . HashMap Clear() method program
303 . HashMap ContainsKey() method program
304 . HashMap Containsvalue() method program
305 . HashMap PutAll() method program
306 . HashMap Clone() method program
307 . HashMap Size() method program
308 . Hashtable Put(Key,Value) method program
309 . Hashtable Get() method program
310 . Hashtable IsEmpty() method program
311 . Hashtable Remove() method program
312 . Hashtable Size() method program
313 . Hashtable Keyset() method program
314 . Hashtable Value() method program
315 . Hashtable Clear() method program
316 . Hashtable ContainsKey() method program
317 . Hashtable Containsvalue() method program
318 . Hashtable PutAll() method program
319 . Hashtable Clone() method program
320 . Hashtable Size() method program
321 . Foreach loop program
322 . Iterator Interface program
323 . ListIterator Interface program
324 . Enumeration Interface program
325 . StringTokenizer class program
326 . Space dilimiter Example
327 . Count The Number of Words in a Given String
328 . Enumeration Interface Example
329 . Calendar Class Program
330 . Month Program
331 . Year Program
332 . Hour Program
333 . Minute Program
334 . Seconds Program
335 . AM_PM Program
336 . DAY_OF_Year Program
337 . Addition Program:Please execute a program in a particular time and date
338 . FileInputStream class program
339 . DataInputStream class program
340 . SequenceInputStream class program
341 . ByteArrayInputStream class program
342 . BufferedInputStream class program
343 . ObjectInputStream class program
344 . FileOutputStream class program
345 . DataOutputStream class program
346 . ByteArrayOutputStream class program
347 . BufferedOutputStream class program
348 . ObjectOutputStream class program
349 . FileReader Class program
350 . CharacterArray Classes program
351 . BufferedReader Classes program
352 . FileWriter Class program
353 . CharacterArrayWriter Classes program
354 . BufferedWriter Classes program