Java

Java Program to Check Even and Odd Number – Java Programming Interview Questions

Java Program to Check Even and Odd Number

By Bhau Automation • Java Programming Interview Series

🎯 What You Will Learn

  • What is an Even Number?
  • What is an Odd Number?
  • Java Program to Check Even or Odd
  • Using Modulus (%) Operator
  • Real-Time Java Examples
  • Java Interview Questions
  • Programming Best Practices
💡 Checking whether a number is Even or Odd is one of the most common Java programming interview questions for freshers.

📌 What is an Even Number?

An Even Number is any integer that is completely divisible by 2. When divided by 2, the remainder is 0.

Examples: 2, 4, 10, 24, 100

📌 What is an Odd Number?

An Odd Number is any integer that is not divisible by 2. When divided by 2, the remainder is 1.

Examples: 1, 3, 5, 11, 99

💻 Java Program to Check Even and Odd Number

public class EvenOddExample {

    public static void main(String[] args) {

        int number = 25;

        if(number % 2 == 0){
            System.out.println(number + " is Even");
        }else{
            System.out.println(number + " is Odd");
        }

    }

}

🖥️ Output

25 is Odd

📌 Logic Behind the Program

  • If number % 2 == 0 → Even Number
  • Otherwise → Odd Number
  • The modulus (%) operator returns the remainder.

📊 Real-Time Applications

  • Mathematical calculations
  • Data validation
  • Programming interviews
  • Competitive coding
  • Algorithm development

🎯 Practice Java Programming

Practice More Java Programs:

Visit https://www.bhauautomation.com

Navigate to:
Services → Java Programming Tutorials

❓ Java Interview Questions

Q1. Which operator is used to check Even and Odd numbers?

The Modulus (%) operator.

Q2. What is the condition for an Even number?

number % 2 == 0

Q3. What is the condition for an Odd number?

number % 2 != 0

Q4. Why is the modulus operator used?

Because it returns the remainder after division.

🎥 Watch Complete Video Tutorial

Watch Java Even Odd Program Tutorial

🔥 Key Takeaways

  • Even numbers are divisible by 2.
  • Odd numbers leave remainder 1.
  • The modulus operator (%) is the simplest solution.
  • This is one of the most frequently asked Java interview programs.
  • Practice similar Java programs to improve coding skills.
⚡ Master Java programming basics like Even and Odd programs to crack Java, Selenium and Automation Testing interviews with confidence.

🚀 Created with ❤️ by Bhau Automation