0% found this document useful (0 votes)
15 views3 pages

Top 60 Java Coding Questions & Answers

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

Top 60 Java Coding Questions & Answers

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

TOP 60 JAVA CODING QUESTIONS WITH ANSWERS

(Shortened PDF Version – Full detailed explanations can be requested again)

1. Reverse String:
String rev = new StringBuilder(s).reverse().toString();

2. Palindrome String:
[Link](new StringBuilder(s).reverse().toString());

3. Count Vowels & Consonants:


Check vowels using "aeiou".indexOf(ch)

4. Duplicate Characters:
Use HashMap

5. Check Anagram:
Sort both strings and compare.

6. Max & Min in Array:


Loop and track max/min.

7. Second Largest:
Track max and secondMax.

8. Reverse Array:
Swap using two pointers.

9. Remove Duplicates:
Use HashSet.

10. Missing Number:


Sum formula n(n+1)/2 - array sum.

11. Prime Number:


Check divisibility till sqrt(n).

12. Fibonacci:
Iterative loop.

13. Factorial:
Use loop or recursion.

14. Armstrong Number:


Sum of cubes of digits = number.

15. Strong Number:


Sum of factorials of digits.

16. Perfect Number:


Sum of divisors = number.

17. Reverse Number:


Use modulo and division.

18. Palindrome Number:


Compare reversed with original.

19. Sum of Digits:


While loop with %10.

20. GCD:
Euclid algorithm.

21. LCM:
(a*b)/gcd.

22. Linear Search:


Scan array.

23. Binary Search:


Midpoint logic.

24. Bubble Sort


25. Selection Sort
26. Insertion Sort

27. Merge Sort


28. Quick Sort

29. Largest of 3 Numbers


30. Smallest of 3 Numbers

31. Count Frequency (HashMap)


32. Two Sum Problem
33. Move Zeros to End
34. Count Even/Odd in Array
35. Sort String Characters
36. First Non-Repeating Character
37. Remove Whitespaces
38. Toggle Case
39. Largest Word in Sentence
40. Count Words
41. Matrix Diagonal Sum
42. Matrix Boundary Print
43. Matrix Transpose
44. Matrix Search Element
45. Pattern – Right Triangle
46. Pattern – Pyramid
47. Pattern – Diamond
48. Pattern – Number Triangle

Linked List Important:


49. Reverse Linked List
50. Detect Loop (Floyd's Algo)
51. Middle of Linked List
52. Remove Duplicates (Sorted)

Stack/Queue:
53. Valid Parentheses
54. Implement Stack using Array
55. Implement Queue using Array
56. Reverse Stack

More:
57. Check Substring
58. Array Rotation
59. Intersection of Arrays
60. Union of Arrays

(Note: Full detailed codes for all 60 can be generated anytime.)

You might also like