500 Java Logic Building Questions (Easy to Hard)
By ChatGPT (GPT-5)
1. Basics and Operators (1 – 20)
Print “Hello World” in Java.
Add two numbers entered by the user.
Check if a number is even or odd.
Find the greatest of two numbers using if-else.
Find the greatest of three numbers.
Check if a number is positive, negative, or zero.
Swap two numbers using a temporary variable.
Swap two numbers without using a third variable.
Check if a year is a leap year.
Calculate the area of a circle.
Calculate the perimeter of a rectangle.
Find simple interest.
Find compound interest.
Convert Celsius to Fahrenheit.
Convert kilometers to miles.
Calculate the average of three numbers.
Check if a number is divisible by 5 and 11.
Display ASCII value of a character.
Check if a character is a vowel or consonant.
Compute the square and cube of a number.
2. Loops and Conditionals (21 – 40)
Print numbers from 1 to 100.
Print even numbers from 1 to 100.
Print odd numbers from 1 to 100.
Find the sum of first N natural numbers.
Find factorial of a number.
Reverse digits of a number.
Check if a number is a palindrome.
Count the digits of a number.
Find the sum of digits of a number.
Print multiplication table of any number.
Print Fibonacci series up to N terms.
Check if a number is an Armstrong number.
Check if a number is a perfect number.
Find the power of a number without using [Link]().
Check whether a number is prime.
Print all prime numbers between 1 and 100.
Find GCD (HCF) of two numbers.
Find LCM of two numbers.
Display all factors of a number.
Count number of even and odd digits in a number.