Practice Core Java Basics in Java

Learn fundamental Java concepts including variables, data types, operators, and basic I/O operations.

Work through 26 exercises with starter code, expected output, test cases, and hints.

Core Java Basics exercises

  1. Declare Variables Java exercise — Declare and print different variable types
  2. Swap Two Values Java exercise — Swap the values of two variables
  3. Type Casting Java exercise — Convert between different data types
  4. Arithmetic Operations Java exercise — Perform basic math operations
  5. String Concatenation Java exercise — Combine strings together
  6. Modulus Operator Java exercise — Use modulus to get remainder
  7. Sum of Digits Java exercise — Calculate the sum of all digits in a number
  8. Reverse a Number Java exercise — Reverse the digits of an integer
  9. Count Digits Java exercise — Count the number of digits in an integer
  10. Calculate Power Java exercise — Calculate base raised to exponent without Math.pow
  11. Calculate Factorial Java exercise — Calculate factorial of a number
  12. Palindrome Number Check Java exercise — Check if a number is a palindrome
  13. Greatest Common Divisor Java exercise — Find GCD of two numbers
  14. Least Common Multiple Java exercise — Find LCM of two numbers
  15. Armstrong Number Check Java exercise — Check if a number is an Armstrong number
  16. Perfect Number Check Java exercise — Check if a number is perfect
  17. Number to Words Java exercise — Convert a single digit to its English word
  18. Triangle Type Checker Java exercise — Determine if sides form a valid triangle and its type
  19. Happy Number Check Java exercise — Check if a number is a happy number
  20. Strong Number Check Java exercise — Check if a number is a strong number
  21. Automorphic Number Check Java exercise — Check if a number is automorphic
  22. Binary to Decimal Java exercise — Convert a binary string to its decimal equivalent
  23. Decimal to Binary Java exercise — Convert a decimal number to its binary representation
  24. Prime Factorization Java exercise — Find all prime factors of a number
  25. Harshad Number Check Java exercise — Check if a number is divisible by sum of its digits
  26. Neon Number Check Java exercise — Check if sum of digits of square equals the number

Browse the complete Java practice path · Open the online Java compiler