All Basic Programs in java with examples

  1. Write a Java program to print ‘Hello World!’ on screen
  2. Write a Java program to print the sum of two numbers
  3. Write a Java program that takes two numbers and display the product of two numbers
  4. Write a Java program to print the sum, multiply, subtract, divide and remainder of two numbers
  5. Write a Java program that takes five numbers as input to calculate and print the average of the numbers
  6. Write a Java program to swap two variables
  7. Write a Java program to convert a decimal number to binary numbers
  8. Write a Java program to convert a binary number to decimal number
  9. Write a Java program to check whether Java is installed on your computer or not
  10. Write a Java program and compute the sum of the digits of an integer
  11. Write a Java program to compare two numbers
  12. Write a Java program to count the letters, spaces, numbers and other characters of an input string
  13. Write a Java program to print the ascii value of a given character
  14. Write a Java program that accepts an integer (n) and computes the value of n+nn+nnn
  15. Write a Java program to display the system time
  16. Write a Java program to print the odd numbers from 1 to 20
  17. Write a Java program to print the even numbers from 1 to 20
  18. Write a Java program to convert a string to an integer
  19. Write a Java program to convert seconds to hour, minute and seconds
  20. Write a Java program to compute the sum of the first 100 prime numbers
  21. Write a Java program to swap the first and last elements of an array and create a new array
  22. Write a Java program to count the number of even and odd elements in a given array
  23. Write a Java program to compute the square root of an given integer
  24. Write a Java program to check if a positive number is a palindrome or not
  25. Write a Java program to add two numbers without using any arithmetic operators
  26. Write a Java program to add all the digits of a given positive integer

Leave a Comment