Java Basics Programs (Variables, Datatypes, Operators)

Back To Java Index


1. program to display hello world on the output screen - Code
2. program to input an integer (or number) and display its value - Code
3. program to input two numbers or integers and display their values - Code
4. program to input three numbers and display their values - Code
5. program to input two numbers and find their sum - Code
6. program to input three numbers and find sum of three numbers - Code
7. program to input two numbers and find the difference between them - Code
8. program to input two numbers and find their product - Code
9. program to input two numbers and display their quotient (division) - Code
10. program to input two numbers and find their remainder (division) - Code
11. program to enter a character and display its value - Code
12. program to input a float value (number with decimal point) - Code
13. program to add two decimal point values - Code
14. program to input two decimal point numbers and display difference between them - Code
15. program to input two float (decimal point) values and find their product - Code
16. program to input principal, rate of interest and time and compute simple interest - Code
17. program to input length and breadth of rectangle and find area of rectangle - Code
18. program to input length and breadth of rectangle and compute perimeter of rectangle - Code
19. program to input side of square and compute area of square - Code
20. program to input side of square and find perimeter of square - Code
21. program to input base and height of right angled triangle and find area of right angled triangle - Code
22. program to input radius of circle and find area of circle - Code
23. program to input radius of circle and find circumference of circle - Code
24. program to demonstrate increment(++) operator , i++ is same as i=i+1 - Code
25. program to demonstrate deccrement(--) operator , i-- is same as i=i-1 - Code
26. program to assign value 10 to a, initializing variable a - Code
27. program to demonstrate (+=) operator, a+=2 is same as a=a+2 - Code
28. program to demonstrate (-=) operator, a-=2 is same as a=a-2 - Code
29. program to demonstrate (*=) operator, a*=2 is same as a=a*2 - Code
30. program to demonstrate (/=) operator, a/=2 is same as a=a/2 - Code
31. program to demonstrate (%=) operator, a%=2 is same as a=a%2 - Code
32. program to input price of an item from user and calculate discount as 10 percent on the price - Code
33. program to find volume of box based on width,depth and height - Code
34. program to demonstrate ternary operator or conditional operator, displays 'p' if marks>=40 else displays 'f' - Code
35. program to declare a constant using final keyword - Code
36. program to enter a boolean and display its value - Code
37. program to input a double value (number with decimal point ) - Code
38. program to input two float (decimal point ) values and find their division - Code