[Go to site: main page, start]

0% found this document useful (0 votes)
6 views2 pages

Essential Java Programming Challenges

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Essential Java Programming Challenges

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Programming Questions

1. Reverse a given string.


2. Check if a given string is a palindrome.
3. Find the factorial of a number using recursion.
4. Print the Fibonacci series up to N terms.
5. Check whether a number is prime or not.
6. Swap two numbers without using a temporary variable.
7. Count the number of vowels in a string.
8. Find the largest element in an array.
9. Count the frequency of words in a given sentence.
10. Reverse an integer.
11. Implement bubble sort on an integer array.
12. Implement selection sort on an array.
13. Print a pyramid pattern of stars.
14. Print a left-aligned triangle pattern.
15. Count the total number of characters in a text file.
16. Read a file line by line and display it on console.
17. Implement a stack using an array.
18. Implement a queue using an array.
19. Find duplicate elements in an integer array.
20. Find the second largest number in an array.

21. Calculate the power of a number (e.g., base^exponent using loops or recursion)

22. Sum of digits of a given integer (e.g., sum each digit of n)

23. Print the largest number among three inputs using conditional (ternary) operator

24. Compute the “digital root” (generic root) of a number: repeatedly sum digits until a single
digit remains

25. Check if a number is a palindrome (using arithmetic operations)

26. Print all prime numbers in a given range (e.g. 1–100)

27. Reverse an array or a string based on input

28. Check whether two strings are anagrams (characters arranged differently)

29. Find the most consecutive occurrence of a character in a string (e.g. “aaaabbcbbb” →4)

30. Sort paired lists by another list’s values (e.g. sort names by age)

31. Determine net direction from displacement in four directional distances (e.g. east, north, west,
south inputs → output direction)

32. Count and classify distinct barking patterns in a pattern string (e.g. “b..bb..b...bb” → number
of dogs)

33. Implement LRU (Least Recently Used) cache using LinkedHashMap or other data structures
34. Reverse a linked list; detect cycle; find midpoint or Nth node from end in linked list

35. Serialize and deserialize a binary search tree (BST) or other binary trees

36. Count number of islands in a matrix (DFS/BFS)

37. Print spiral traversal of a matrix

38. Find longest palindromic substring in a string

39. Rotate an array by K positions (left or right shift)

40. Find kth smallest or largest number in an unsorted array

41. Solve two-sum or N-sum problem using efficient data structures

42. Convert infix expression to postfix or evaluate arithmetic expression

43. N-Queens backtracking problem or generate subsets/permutations

44. Implement DFS/BFS on graphs, and shortest-path algorithms such as Dijkstra

45. Implement a basic calculator (supporting +, –, ×, ÷) with proper input validation

You might also like