[Go to site: main page, start]

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

Java Interview Questions: Easy to Advanced

The document lists Java coding interview questions categorized into easy, medium, and advanced levels. It includes 25 questions covering topics such as string manipulation, array operations, recursion, and data structures. Each question provides an example input and expected output to illustrate the problem.

Uploaded by

vinayhp.xworkz
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)
8 views3 pages

Java Interview Questions: Easy to Advanced

The document lists Java coding interview questions categorized into easy, medium, and advanced levels. It includes 25 questions covering topics such as string manipulation, array operations, recursion, and data structures. Each question provides an example input and expected output to illustrate the problem.

Uploaded by

vinayhp.xworkz
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 Coding Interview Questions (1–25)

🟢 Easy-Level (1–10)

1. Reverse a String

○ Input: "hello" → Output: "olleh"

2. Check if a number is prime

○ Input: 13 → Output: true

3. Find the factorial of a number using recursion

○ Input: 5 → Output: 120

4. Check if a string is a palindrome

○ Input: "madam" → Output: true

5. Find the largest element in an array

○ Input: [1, 4, 9, 2] → Output: 9

6. Move all zeros to the end of the array

○ Input: [0, 1, 0, 3, 12] → Output: [1, 3, 12, 0, 0]

7. Find the missing number in an array from 1 to N

○ Input: [1, 2, 4, 5] → Output: 3

8. Rotate an array to the right by K steps

○ Input: [1, 2, 3, 4, 5], k = 2 → Output: [4, 5, 1, 2, 3]

9. Check if a string has all unique characters

○ Constraint: No additional data structures allowed.

10. Compress a string using counts of repeated characters

● Input: "aabcccccaaa" → Output: "a2b1c5a3"


🟡 Medium-Level (11–20)

11. Check if two strings are anagrams

● Input: "listen", "silent" → Output: true

12. Find the first non-repeating character in a string

● Input: "swiss" → Output: "w"

13. Sort an array using bubble sort (or other)

● Input: [3, 1, 5, 2] → Output: [1, 2, 3, 5]

14. Fibonacci series (recursive and iterative)

● Input: n = 7 → Output: 0 1 1 2 3 5 8

15. Greatest Common Divisor (GCD) using Euclidean algorithm

● Input: GCD(54, 24) → Output: 6

16. Count number of digits in an integer without converting to string

● Input: 12345 → Output: 5

17. Check if a number is an Armstrong number

● Input: 153 → Output: true

18. Implement a simple LRU Cache using LinkedHashMap

19. Implement a stack using two queues

20. Implement a queue using two stacks

🔴 Advanced-Level (21–25)

21. Detect a cycle in a linked list

● Use Floyd’s Tortoise and Hare algorithm.

22. Find the intersection point of two linked lists

● Return the node where they merge.


23. Implement a multi-threaded counter using synchronized or AtomicInteger

● 10 threads increment a counter 1000 times → Output: 10000

24. Print even and odd numbers using two threads in sequence

● Thread A prints even, Thread B prints odd, alternately.

25. Create a thread-safe singleton class in Java

You might also like