Member-only story
Java Coding Interview Questions: Top 10
Tabble of Contents
· 1. FizzBuzz Problem
· 2. Reverse a String
· 3. Find the Missing Number
· 4. Check if a String is Palindrome
· 5. Detect Duplicate Elements in an Array
· 6. Implement a Stack Using Arrays
· 7. Find the Longest Common Prefix
· 8. Count Words in a Sentence
· 9. Find the Maximum Subarray Sum
· 10. Check if a Number is Prime
∘ Insights from the Interview Corner Navigating 2024 Landscape
· Java Interview Questions
Not a Premium Medium member? Click here to access it for free!
1. FizzBuzz Problem
Write a program that prints the numbers from 1 to 100. But for multiples of three, print “Fizz” instead of the number, and for the multiples of five, print “Buzz”. For numbers that are multiples of both three and five, print “FizzBuzz”.
Here’s the FizzBuzz problem solved in Java:
public class FizzBuzz {
public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {…