Java programs for interviews,

Java programs for interviews


String-Based Programs

  1. Reverse each word in a sentence

  2. Check if a string is a palindrome

  3. Count vowels and consonants in a string

  4. Remove duplicate characters from a string

  5. Find the first non-repeated character

  6. Check if two strings are anagrams

  7. Count frequency of characters in a string

  8. Convert string to title case (capitalize first letter)

  9. Check for substring without using in-built methods

  10. Replace all spaces with hyphens (-)


Array-Based Programs

  1. Find the largest and smallest number in an array

  2. Find duplicate elements in an array

  3. Sort an array without using built-in methods

  4. Remove duplicates from an array

  5. Reverse an array

  6. Find the second largest number

  7. Count the frequency of each element

  8. Merge two arrays

  9. Find the common elements between two arrays

  10. Rotate an array to the left/right


Number-Based Programs

  1. Check if a number is prime

  2. Generate Fibonacci series

  3. Check if a number is Armstrong

  4. Find factorial of a number

  5. Check if a number is palindrome

  6. Swap two numbers without using a third variable

  7. Print all prime numbers between 1 and 100

  8. Find GCD and LCM of two numbers

  9. Convert decimal to binary

  10. Count digits in a number


Pattern Programs

  1. Pyramid pattern

  2. Diamond pattern

  3. Floyd's triangle

  4. Pascal’s triangle

  5. Right-angled triangle of numbers/stars

  6. Inverted triangle pattern

  7. Hourglass/star pattern

  8. Number increasing pattern

  9. Zigzag pattern

  10. Hollow rectangle


Logic Building/General

  1. Check if a year is a leap year

  2. Print multiplication table of a number

  3. Sum of digits of a number

  4. Reverse digits of a number

  5. Print even and odd numbers from 1 to N

  6. Count the number of words in a sentence

  7. Check if input is numeric (without try-catch)

  8. Find repeated words in a sentence

  9. Calculate power of a number without using Math.pow()

  10. Find missing number in a sequence (like 1-100, missing 34)



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