https://github.com/mdmohsinhaider/java-program
java programing
https://github.com/mdmohsinhaider/java-program
collections-framework core java java-8 leetcode-java programming solutions
Last synced: 9 months ago
JSON representation
java programing
- Host: GitHub
- URL: https://github.com/mdmohsinhaider/java-program
- Owner: MdMohsinHaider
- License: mit
- Created: 2024-10-10T13:48:39.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-09T11:07:16.000Z (10 months ago)
- Last Synced: 2025-03-09T11:18:06.681Z (10 months ago)
- Topics: collections-framework, core, java, java-8, leetcode-java, programming, solutions
- Language: Java
- Homepage:
- Size: 194 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java-programing Questions
### Java programming at J/Q/Spider Noida B-4, Block B, Sector 3, Noida, Uttar Pradesh 201301
### Trainer : `Shambhu Sir`
# 1. Number
1. Take input a random number from the user and check the number is Even or Odd number and Print.
2. Take Input a Random Number from the user and print the last three-digit number.
3. Take Input a Random Number from the user and print the last second digit number.
4. Take Input a Random Number from the user and print the first three-digit number.
5. Write a java Program to print all the even numbers up to 100.
6. Write a java Program to print all the numbers with user input range between and ends with 7.
7. Write a Java Program to print all the numbers up to 1000 which ends with 8 and divided by 8.
8. Write a Java Program to print all the numbers in between 1000 and 2000 and number ends with 7 and divided by 7 and also prints amounts of counts occurrence.
9. Write a java program to print all the factors from the user given number (number itself not included).
10. Take user input print and count all the factors of the number.
11. Take two user input numbers and print all the prime numbers in between (number itself not included).
12. Take the user input number and check if the number is prime or not.
13. Write a Java Program to calculate the sum of the series below.
14. `1+2+3+__________________+100.`
15. `1^2+1^2+2^2+3^2+----------------+100^2.`
16. `1^3+2^3+3^3+4^3+__________________+100^3.`
17. `1^4 + 2^4 + 3^4 +__________________+100^4.`
18. `1*2 + 2*3 + 3*4 + 4*5 + _____________+ 99*100.`
19. `1*2^2+ 2*3^2 + 3*4^2 + 4*5^2 + _____________+ 99*100^2.`
20. `1^2*2 + 2^2*3 + 3^2*4 + 4^2*5 + _____________+ 99^2*100.`
21. `1/1 + ½ + ⅓ + ¼ + ___________+1/100.`
22. `1/1^2 + 1/2^2 + 1/3^2 + 1/4^2 + ___________+1/100^2.`
23. `1-2+3-4+5-6+7-8+ ______________+99-100.`
24. `1/1 - ½ - ⅓ - ¼ - ___________-1/100.`
25. `1/1*2 + 1/2*3 + 1/3*4 + ___________+ 1/99*100.`
26. Take user input print factorial of number.
27. Take two input numbers from the user and calculate the power of the number.
28. Take user input and generate many terms in the fibonacci series.
29. Write a java Program to check whether the number is palindrome or not.
30. Write a java program to print factors of the number if the number is palindrome.
31. Take user input and print whether the number is a perfect number or not.
32. Take user input and print the factorial of the given number.
33. Take user input and print a table with that user n number.
34. Take user input and print a table from the user range and that number.
35. Write a java Program to check and print number is Happy Number or not.
36. Write a java Program to check and print number is Ugly Number or not.
37. Write a java Program to check and print number is the Second Maximum Number.
38. Write a java Program to check and print number is the Third Maximum Number.
39. Write a java Program to check and print number is the Second last minimum Number.
40. Write a java Program to check and print number is the third last minimum Number.
41. Write a java Program to check and print number is Armstrong Number or not.
# 2. Digits
1. Write a java program to print each digit of number one by one.
2. Write a java program to print all even digits.
3. Write a java program to print all odd digits.
4. Write a java program to print all digits and also handle zero if the number has the first digit is 0.
5. Write a java Program to count number’s digits present in the number.
6. Write a java Program to count even digits present in the given number.
7. Write a java Program to count odd digits present in the given number.
8. Write a java program to print the biggest digits of the number.
9. Write a java program to print the Smallest digits of the number.
10. Write a java Program to print different of biggest and smallest digits.
11. Write a java Program to check whether the product of sum of digits is even or odd.
12. Write a Java Program to calculate the sum of each digit of the number.
13. Write a java Program to calculate the sum of all digits of the number and check the sum of digits odd or even.
14. Write a java Program to calculate factorial of each digit of the number.
15. Write a java Program to calculate the sum of factorial of each digit of a number.
16. Write a java Program to check whether the number is a Strong number or not.
17. Write a java program to reverse digits.
18. Write a java Program to find the difference between reverse and original digits/number if the number is different from original and reverse.
19. Write a java Program to check if the reverse and original number is divisible or not, if Divisible then print.
20. Write a java program to check the sum of reverse and original number/digits is even or odd if the number is odd then print all odd digits, but the number is even then print all the even digits.
21. Take user input and print the Sum, digits of all factorials.
22. Write a java program and print the Second-Largest Digit in a String.
# 3. String and Charter (Part I)
1. 🟢 Take String input from the user and print character one by one From Starting.
2. 🟢 Take String input from the user and print character one by one From Ends.
3. 🟢 Take String input from the user and Get the Length of a String.
4. 🟢 Take Two String input from the user and join Two Java Strings to each other.
5. 🔴 Write a java Program, take input two string from user and compare both string and find Unique and duplicate Character String.
6. 🟢 Take input String From User and convert all the characters to lowercase.
7. 🟢 Take user input String and print the String if String is palindrome.
8. 🟢 Take String and print voles and total number of Voles counts
9. 🟢 Take String and print consonants and total number of Consonants counts.
10. 🟢 Take String random symbol Input from user and return all alphabets.
11. 🟠 For a given String contain numeric character count the number of Numeric Charters find a sum these numeric charter.
12. 🔴 For a Given String Count the total number of Words in the String.
13. 🟠 Write a java Program to take String And reverse By using String User Method and return.
14. 🟠 Write a java program, for the given String is palindrome or not.
# 4. String-based Programming (Part II)
1. Write a Java Program to take a String input to get length of String without using length method.
2. Write a Java Program to take a String input and count all numeric characters in the String.
3. Write a java Program to take a String input and count all the characters without spaces in the String.
4. Write a Java Program to take a String input and count all the characters (excluding any special characters).
5. Write a Java Program to take a String input and count all the space characters, uppercase, lowercase, numeric, special characters in the String.
6. Write a Java Program to take a String input and count all the vowel characters in the String.
7. Write a Java Program to take a String input and print all the indexes where numeric characters are present in the String.
8. Write a Java Program to take a String input and print all the indexes where space characters are present in the String.
9. Write a Java Program to take a String input and replace all the space characters from _ in the String.
`a)By using replace() method
b)Without using replace() method`
10. Write a Java Program to take a String input and print the sum of all the numeric characters in the String.
11. Write a Java Program to take a String input and print sum of all the even numeric characters in the String.
12. Write a Java Program to take a String input and reverse the String.
13. Write a Java Program to take a String input and check whether the String is a Palindrome String or not(without reversing).
14. Write a Java Program to take a String input and remove all the duplicate characters and store in another String.
15. Write a Java Program to take a String input and count the total number of words in the String (Without using split method).
16. Write a Java Program to find a string is `ANAGRAM` or not? [`Leetcode`](https://leetcode.com/problems/valid-anagram/description/)
17. Write a Java Program to find weather a string is `PANAGRAM` or not? [`Leetcode`](https://leetcode.com/problems/check-if-the-sentence-is-pangram/description/)
18. Second-largest Number in String: [`Leetcode`](https://leetcode.com/problems/second-largest-digit-in-a-string/description/)
19. Write a Java Program for the below requirements:
`i/p: mohan and sohan are here.
o/p: here are sohan and mohan`
20. Write a Java Program for the below requirements:
`i/p: mohan and sohan are here.
o/p: nahom dna nahos era ereh.`
21. Write a Java Program, take a String input and print and count all the words that have even numbed of characters.
22. Write a Java Program, take a String input and print the largest word in the String.
23. Write a Java Program, take a String input and print the index and value of first non-repeating character.[`Leetcode`](https://leetcode.com/problems/first-unique-character-in-a-string/description/)
24. Write a Java Program to convert the first character of each word of a String into upper case.
25. Write a Java Program to take a String input and convert all the lowercase characters to uppercase.
26. Write a Java Program to check if a string contains only digits.
27. Write a Java Program to print the frequency of each character in the String.
28. [`Leetcode`](https://leetcode.com/problems/sort-characters-by-frequency/description/)
29. [`Leetcode`](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/description/)
30. Write a Java Program to print all the characters which appeared only once in the String.
31. Write a Java Program to print the character which is appeared only once in the String. Given that, only one character has appeared once in the string.
32. Write a Java Program to print all the characters which appeared more than once in the String.
33. Write a Java Program to print the character which is appeared for the maximum times in the String.
34. Write a Java Program to print the character which is appeared for the maximum times in the String.
If more than one character has appeared for maximum time, return the smallest character.
35. Write a Java Program to print the character which is appeared for the maximum times in the String.
If more than one character has appeared for maximum time, return the biggest character.
36. given a string of Size N containing digits from 1 to N where any one digit is missing, Print the missing digit.
37. Write a Java Program to print the frequency of each word in a string.
38. Write a Java Program to print the first character of each word in the String.
39. Write a Java Program to print and count all the words which has appeared only once in the String.
`Input: mohan is coming and sohan is coming
Output:
mohan
coming
and
sohan
Total words: 4`
40. Write a Java Program to print and count all the duplicate words in the String.
`Input: mohan is coming and sohan is coming and
Output:-
is
coming
Total words: 2`
41. Write a Java Program to print the word which has appeared for maximum times in the String.
`Input: mohan is coming and sohan is coming is good
Output:
is`
42. Write a Java Program to count the occurrence of a particular word in the String.
`Input: mohan is coming and sohan is coming
“is”
`Output:`
The word “is” has appeared 2 times`
43. Write a Java Program to remove duplicate words from the String.
`Input: mohan is coming and sohan is coming`
`Output: mohan is coming and sohan`
44. Write a Java Program to perform sorting for a group of Strings.
45. Write a Java Program to convert the first character of each sentence in a string to upper case.
46. Write a Java Program to convert the first character of each sentence to upper case and all the other characters of string into lower case.
47. Write a Java Program to exchange a given input with target input( fg with cd).
`Input: abcdefgh`
`Output: abfgecdh`
48. What is the purpose of String[] args in the main method.
49. Write a Java Program to convert any four-digit NUMBER into WORDS.
50. Write a Java Program to print the first character of each word.
51. [`Leetcode`](https://leetcode.com/problems/valid-palindrome/description/)
52. [`Leetcode`](https://leetcode.com/problems/find-the-closest-palindrome/description/)
53. Write a Java Program to Find All the Permutations of a String.
`Input: abc`
`Output:`
`abc`
`acb`
`bac`
`bca`
`cab`
`cba`
54.
# 5. Pattern
1. Print the pattern different types' triangle.
2. Print the pattern different types Square.
3. Print the pattern different types Rectangle.
4. Print the pattern different types of Stars.
5. Print the pattern `Damru`
6. Print the pattern alphabet A to Z.
# 6. Recursion
1. Write a java Program all the numbers from 1 to 100 using recursion.
2. Write a java Program to generate numbers from 100 to 1 by using recursion.
3. Write a java Program to generate tables using recursion.
4. Write a java Program to Print the Sum of numbers from 1 to 100 by using recursion.
5. Write a java Program to Print the Sum of Square of number from 1 to 100 by using recursion.
6. Write a java Program to calculate factorial using recursion.
7. Write a java Program to calculate power using recursion.
8. Write a java Program to count digits using recursion.
9. Write a java Program to calculate the Sum of digits using recursion.
10. Write a java Program to reverse a number using recursion.
11. Write a java program to Check if the number is palindrome or not using recursion.
12. write a java program to print to generate numbers from 1 to 10 by using recursion.
13. write a java program to print to generate table of a number by using recursion.
14. write a java program to print a sum of numbers from 1 to 100 by using recursion.
15. write a java program to print a sum of squares of numbers from 1 to 100 by using recursion.
16. write a java program to print to calculate factorial by using recursion.
17. write a java program to print to calculate power by using recursion.
18. write a java program to print to get digit count of a number by using recursion.
19. write a java program to print to get a digit sum of a number by using recursion.
20. write a java program to print to reverse a number by using recursion.
21. write a java program to print to check a palindrome number by using recursion.
22. write a java program to print to take Four user inputs and print the biggest of that.
23. write a java program to print to calculate nth term of Fibonacci series by using recursion.
24. write a java program to print to generate n term of Fibonacci series by using recursion.
25. write a java program to print to take three user inputs and print HCF of the three numbers.
26. write a java program to print to take three user inputs and print LCM of the three numbers.
# 7. Arrays
1. 🟢 Print all the elements in sequence array.
2. 🟢 Print all the elements in a reverse order array.
3. 🟢 Print all the even elements array.
4. 🟢 Print all the even indexed of elements
5. 🟢 Calculate a print sum of all elements of array
6. 🟢 Calculate and print the sum of all the numbers of the array which is divisible by 4.
7. 🟢 Calculate and print the biggest element of an array
8. 🟠 Design a method which will return the biggest and smallest difference.
9. 🟢 Design a method which will return true if it contains only even numbers
10. 🟢 Design a method which will return if the product of array is even
11. 🟢 Design a method that accepts string arrays will print the size of every string element.
12. 🟢 Design a method which will accept a string array and will print and count all the even length string elements.
13. 🟢 Design a method which will accept a string array and will return the string with the biggest size
14. 🟢 Design a method to check if an array is strictly increasing or not and will return.
15. 🟠 Design a method to remove an element from a particular position of an array.
16. 🟠 Design a method which will insert and at array at any given position.
17. 🔴 For a given array which contains positive number (0 < = arr[i] < = 100). print the frequency of each array element.
18. 🔴 print events only one in the array.
19. 🔴 Print all the elements that have appeared more than ones.
20. 🔴 Print All the elements exactly once
21. 🔴 print elements appeared evens types in an array.
22. 🔴 Print all the array elements which appear odd numbers of times.
23. 🔴 Print the elements that have appeared for the maximum times in an array.
24. 🔴 Print the index and its elements, which are non-repeating elements.
25. 🟢 write a java program to print the even index elements of the array.
26. 🟢 write a java program to print the even elements of the array.
27. 🟢 write a java program to print to count all the even numbers of the array.
28. 🟠 write a java program to print and count all the three-digit numbers of the array.
29. 🟢 write a java program to print sum and average of all the elements of array.
30. 🟠 write a java program to print the Biggest element, Smallest element and their difference in the array.
31. 🟠 For the given array of Strings, print and count all the Strings which has even numbed of characters.
32. 🟢 For the given array of Strings, print the largest string and the smallest string.
33. 🟢 write a java program to print each element of the array in reverse order.
34. 🟠 write a java program to print an alternate element of the array from end.
35. write a java program to print to swap two index values of the array.
36. write a java program to print to insert an element at certain position of the array.
37. write a java program to print to remove an element from the certain position of the array.
38. write a java program to print to check is even or odd without using if else/Conditional Operator statement.
39. write a java program to print and count all the prime numbers of the array.
40. write a java program to print to rotate each element of an array by one position on the right side.
41. write a java program to print to rotate all the elements of array k position to its right.
` array[] = {1,2,3,4,5,6,7},k=2
Output: {6 7 1 2 3 4 5} `
42. write a java program to print to rotate each element of an array by one position on the left side.
43. write a java program to print to rotate all the elements of array k position to its left.
`array[] = {1, 2, 3, 4, 5, 6, 7},k = 2
Output: {3 4 5 6 7 1 2}`
44. [`Leetcode`](https://leetcode.com/problems/rotate-array/description/)
45. [`Leetcode`](https://leetcode.com/problems/move-zeroes/description/)
46. write a java program to print to move all zeroes of an array to the end.
`i/p: [7, 0, 2, 6, 0, 4]
o/p: [7, 2, 6, 4, 0, 0]`
47. write a java program to print the shift all 0’s to left and all 1’s to the right (Without Sorting).
`i/p: [0, 1, 1, 0, 0, 1, 0, 0]
o/p: [0, 0, 0, 0, 0, 1, 1, 1]`
48. For the given array of 0’s, 1’s and 2’s Sort the elements (Without Sorting).
`i/p: [0, 2, 0, 1, 2, 1, 0, 2]
o/p: [0, 0, 0, 1, 1, 2, 2, 2]`
49. [`Leetcode`](https://leetcode.com/problems/sort-colors/description/)
50. write a java program to print the frequency of each element of the array if all given elements are in range from 0 to 1000.
51. write a java program to print the frequency of each element of the array when elements provided are in any range.
52. write a java program to print each element of the array which has appeared only once in the array.
53. write a java program to print each element of the array which has appeared more than once/which has duplicate values in the array.
54. write a java program to print all the elements of array whose frequency is odd.
55. write a java program to print the element and its frequency, which has appeared for the maximum time in the array.
56. write a java program to print the index and the value of the first non-repeating element in an array.
57. write a java program to print to remove the duplicate values from the array and store all unique elements in a new Array.
58. write a java program to print true if all the elements in the array are unique.
59. write a java program to print the Biggest and second-biggest element of the array.
60. write a java program to print the Smallest and second-Smallest element of the array.
61. write a java program to print to find the maximum product of two integers in a given array of positive integers.
62. write a java program to print to sort the array elements in ascending order.
63. write a java program to print to sort the array elements in descending order.
64. write a java program to print first half of the array elements in ascending order and second half of the elements in descending order.
`i/p: [25, 34, 12, 45, 23, 28]
o/p: [12, 25, 34, 45, 28, 23]`
65. write a java program to print first half of the array in ascending order and second half in descending order.
`i/p: [25, 34, 12, 45, 23, 28]
o/p: [12, 23, 25, 45, 34, 28]`
66. write a java program to print true if elements of an array are same when it is read from front or from back otherwise print false.
`i/p: [12, 23, 15, 15, 23, 12]
o/p: true`
67. write a java program to print find missing element
`i/p: [7, 4,3, 5, 1, 6]
o/p: 2`
68. write a java program to print to check if an array is strictly increasing.
`i/p: [2, 3, 7, 8, 9]
o/p: Array is strictly increasing`
69. write a java program to print to check whether a given array is in sorted order or not.
70. [`Leetcode`](https://www.hackerrank.com/challenges/migratory-birds/problem)
71. implement binary search algorithm.
72. [`Leetcode`](https://leetcode.com/problems/first-missing-positive/description/)
73. [`Leetcode`](https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/)
74. [`Leetcode`](https://leetcode.com/problems/count-primes/description/)
75. [`Leetcode`](https://leetcode.com/problems/third-maximum-number/description/)
76. Design a method to rotate one time to the right side.
`int[]a = {1 ,3 ,5 ,7 ,9, 2, 4, 6, 8, 0}
int[]a = {0, 1, 3, 5 ,7, 9, 2, 4, 6, 8}`
77. Design a method rotate elements k times in right side
`int[]a = {1 ,3 ,5 ,7 ,9, ,2, ,4, ,6, ,8, 0}
int[]a = {8, 0 ,1 ,3 ,5 ,7 ,9 ,2 ,4, 6}`
78. Design a method to rotate all the elements one time left side.
` int[]a = {1 ,3 ,5 ,7 ,9, 2, 4, 6, 8, 0}
int[]a = {0, 1, 3, 5 ,7, 9, 2, 4, 6, 8}`
79. Design a method k time to left side.
`int[]a = {1 ,3 ,5 ,7 ,9, 2, 4, 6, 8, 0}
int[]a = {0, 1, 3, 5 ,7, 9, 2, 4, 6, 8}`
80. Design a method to print the biggest and second-biggest element. `17,17,15,14,10,16,17` and `16, 16,15,14,17,16`
81. Design a method to print the smallest and second-smallest element of the array. `5,5,8,7,6,9,5`
82. Write a java Program to move all zeroes of an array to the end. `7,0,2,6,0,4` and output `7,2,6,4,0,0`
# 8. Switch case:
1. write a java program and take user input to calculator to performed calculation.
2. write a java program and take an input option from user and perform a user option.
# COLLECTION FRAMEWORK <------------------------------------------------------>
# 9. Iterator (Collection Framework):
1. write a java program to print even number only from a collection.
2. write a java program to print odd number only from a collection
3. write a java program to print Prime number only from a collection.
4. write a java program to print non=prime number only from a collection.
5. write a java program to print number is palindrome from a collection.
6. write a java program to print number is not palindrome from a collection.
7. write a java program to print number is a strong number from a collection.
8. write a java program to print number is not a strong number from a collection.
# 10. Iterator Loop:
1. Write a java Program to print all the collection with the help of `For each Loop`.
2. Design a method which will accept a collection and will remove all string type elements from the collection.
3. Design a method which will accept a collection and will remove all elements from the collection are not String.
4. Design a method which will remove all the integers from a collection.
5. Design a method which will remove all the elements from a collection which are not an integer.
6. Design a method which will count the integer elements available in a collection.
7. Design a method which will count even integer numbers from a collections.
8. Design a method which will print the sum of all integer numbers from a collection.
9. Design a method which will print the sum of all the even integer numbers from the collection.
10. Design a method which will print the biggest and Smallest integer number from a collection.
# Set(I)
1. From a given array or Arraylist remove all the duplicate elements and print it.
2. From a given array or Arraylist remove all the duplicate elements and return array.
3. From a given array or Arraylist remove all the duplicate elements and return array and change the original array.
4. Print the frequency of each element from an array as well as list.
# Queue(I) :-
1. Short of all the elements of the array.
2. Short of all the elements of the list.
3. Print biggest and second biggest from an array.
4. Print smallest and second smallest from an array.
5. Print biggest and second biggest from a list.
6. Print smallest and second smallest from a list.
# 10. DSA (Data Structures and Algorithms)
## 10.1 Sorting Algorithm
1. Write a java program and implementing a Bubble sort Algorithm.
2. Write a java program and implementing a Selection sort Algorithm.
3. Write a java program and implementing an Insertion sort Algorithm.
4. Write a java program and implementing a Merge sort Algorithm.
## 10.2 Searching Algorithm
1. Write a java program and implementing a Linear (Sequential) Search Algorithm.
2. Write a java program and implementing a Binary Search Algorithm.