Core Java Coding Interview Questions


Core Java Coding Interview Questions

1. String Coding

  1. Reverse a string without using built-in reverse().

  2. Check if a string is a palindrome.

  3. Count the number of vowels and consonants in a string.

  4. Count occurrences of each character in a string.

  5. Find the first non-repeated character in a string.

  6. Remove duplicate characters from a string.

  7. Reverse each word in a sentence.

  8. Check if two strings are anagrams.

  9. Extract only digits from a string.

  10. Find the maximum occurring character in a string.


2. Array Coding

  1. Find the largest and smallest element in an array.

  2. Reverse an array.

  3. Check if an array is sorted or not.

  4. Find duplicate elements in an array.

  5. Remove duplicates from an array.

  6. Find second largest element.

  7. Find missing number in array 1 to N.

  8. Move all zeros to the end of array.

  9. Find pair of numbers whose sum is a given value.

  10. Merge two sorted arrays.


3. Number Programs

  1. Check if a number is prime.

  2. Check if a number is Armstrong.

  3. Check if a number is palindrome.

  4. Find factorial of a number.

  5. Print Fibonacci series.

  6. Find GCD & LCM of two numbers.

  7. Count digits in a number.

  8. Reverse a number.

  9. Find sum of digits.

  10. Check perfect number.


4. Collections Coding

  1. Sort a list without using sort().

  2. Convert array to list and list to array.

  3. Find frequency of each element in list/map.

  4. Remove duplicates from ArrayList.

  5. Find intersection of two lists.

  6. Find union of two lists.


5. Map & Set Coding

  1. Find first non-repeating element using HashMap.

  2. Sort HashMap by key.

  3. Sort HashMap by value.

  4. Check if two HashMaps are equal.


6. Java 8 Coding

  1. Find even numbers from list using streams.

  2. Find max and min using streams.

  3. Convert list to map using streams.

  4. Get duplicate elements using streams.

  5. Count occurrences using streams.


7. Miscellaneous

  1. Swap two numbers without third variable.

  2. Find longest word in a sentence.

  3. Print pattern programs (triangle, pyramid).

  4. Check if a given sentence is pangram.

  5. Implement custom exception.


If you want complete solutions for all 50 coding questions, or want “Selenium + Java coding questions”, just tell me!

Comments

Popular posts from this blog

10 automation test cases for https://www.saucedemo.com/ (Sauce Demo)

Java Roadmap for SDET Superstars!

Mastering XPath in Selenium 4 ๐Ÿš€ – Supported Functions & Axes Explained