Java Question Set
Java Question Set
4. Print all even numbers between 1 and 100 using a while loop.
5. Print all odd numbers between 1 and 100 using a while loop.
12. Find the sum of the first and last digit of a number.
19. Enter a number and print it in words. (Example: 123 -> One Two Three)
Bonus:
markdown
CopyEdit
****
****
****
****
markdown
CopyEdit
****
* *
* *
****
markdown
CopyEdit
**
***
****
markdown
CopyEdit
**
**
****
markdown
CopyEdit
****
***
**
markdown
CopyEdit
****
**
markdown
CopyEdit
***
*****
*******
markdown
CopyEdit
**
* *
*******
markdown
CopyEdit
*******
*****
***
markdown
CopyEdit
*******
* *
**
markdown
CopyEdit
***
*****
***
markdown
CopyEdit
**
* *
**
markdown
CopyEdit
*
**
***
****
***
**
markdown
CopyEdit
**
**
****
**
**
markdown
CopyEdit
*******
* * *
****
** **
****
* * *
*******
markdown
CopyEdit
*******
*****
***
***
*****
*******
markdown
CopyEdit
*******
* *
**
**
* *
*******
CopyEdit
23
456
7 8 9 10
11 12 13 14 15
CopyEdit
12345
6789
10 11 12
13 14
15
markdown
CopyEdit
22
333
4444
55555
markdown
CopyEdit
121
12321
1234321
123454321
yaml
CopyEdit
12
123
1234
12345
yaml
CopyEdit
12345
1234
123
12
yaml
CopyEdit
22
333
4444
55555
CopyEdit
23
456
7 8 9 10
CopyEdit
12345
12345
12345
12345
12345
CopyEdit
1
10
101
1010
10101
markdown
CopyEdit
12
123
1234
12345
markdown
CopyEdit
12345
1234
123
12
markdown
CopyEdit
212
32123
4321234
543212345
4321234
32123
212
1
markdown
CopyEdit
22
3 3
4 4
5 5
4 4
3 3
22
117. Write a program to copy all elements from one array to another.
128. Write a program to count the number of even and odd elements in an array.
129. Write a program to find the pair of elements whose sum is equal to a given number.
130. Write a program to find the missing number in an array of size n containing numbers from 1 to
n+1.
133. Write a program to find the leaders in an array (elements greater than all elements to their
right).
135. Write a program to find the maximum sum subarray (Kadane’s algorithm).
143. Write a program to compare two strings without using library func ons.
152. Write a program to replace all spaces with a given character in a string.
161. Write a program to find the sum of elements of an array using pointers.
165. Write a program to find the maximum element in an array using pointers.
166. Write a program to find the minimum element in an array using pointers.
167. Write a program to find the frequency of elements in an array using pointers.
169. Write a program to demonstrate the use of void pointer (generic references).
170. Write a program to swap two numbers using call by reference (simulate pointers).
Java does not support pointers explicitly for safety reasons, but you can simulate pointer-like
behavior by:
171. Write a program to print the day of the week based on the given number (1 to 7).
172. Write a program to find the number of days in a month using switch-case.
173. Write a program to perform basic calculator opera ons (+, -, *, /) using switch-case.
174. Write a program to check whether a character is a vowel or consonant using switch-case.
175. Write a program to find the grade of a student based on marks using switch-case.
176. Write a program to print the name of the month based on the month number.
177. Write a program to convert a number (1 to 4) to its equivalent season name using switch-case.
179. Write a program to print the day type (weekday/weekend) based on the day number using
switch-case.
180. Write a program to find the quarter of the year based on the month number.
191. Write a program to check whether a triangle is valid or not based on its angles.
194. Write a program to calculate profit or loss based on cost price and selling price.
195. Write a program to check whether a student has passed or failed based on marks.
196. Write a program to check whether an alphabet is vowel or consonant using if-else.