✅ Java Practice Programs (No Loops / No If-Else)

✅ Java Practice Programs (No Loops / No If-Else)

 Beginner-friendly Java practice programs that avoid loops and if-else, focusing only on fundamentals like data types, variables, assignments, initialization, and simple operators. 


  1. ๐Ÿ“ Print your name and age

  2. Add two integers and print the result

  3. Subtract two float numbers and print the result

  4. ✖️ Multiply two double values and print the result

  5. Divide two integers and print the quotient and remainder

  6. ๐Ÿ”„ Swap two numbers using a third variable

  7. ๐Ÿ”ƒ Swap two numbers without using a third variable

  8. ๐Ÿ“Š Assign values to byte, short, int, long, float, and double and print them

  9. ๐Ÿ”— Concatenate and print first name and last name

  10. ๐Ÿ“ Calculate area of a rectangle using length * breadth

  11. Calculate area of a circle (ฯ€ * radius * radius)

  12. ๐ŸŒก️ Convert temperature from Celsius to Fahrenheit

  13. ๐ŸŒก️ Convert temperature from Fahrenheit to Celsius

  14. Check if a number is greater than 10 using logical AND (&&) operator

  15. ๐Ÿ”„ Check if a number is less than 5 or greater than 15 using logical OR (||) operator

  16. ๐Ÿ’ฐ Calculate the simple interest ((P * T * R) / 100)

  17. ๐Ÿ†™ Assign a string and add (concatenate) number 25 to it and print

  18. ๐Ÿ”’ Assign a value to a boolean variable based on an expression and print it

  19. ⚖️ Find the average of three numbers and print the result

  20. ๐Ÿ”ข Print the square and cube of a number


๐Ÿ†• String-Specific Programs

  1. ๐Ÿ”ข Find and print the length of a given string

  2. ๐Ÿ”  Convert a string to uppercase and print it

  3. ๐Ÿ”ก Convert a string to lowercase and print it

  4. ✂️ Extract and print the first 3 characters (substring) from a string

  5. Concatenate two strings with a space in between and print the result

Comments

Popular posts from this blog

10 automation test cases for https://www.saucedemo.com/ (Sauce Demo)

Java Roadmap for SDET Superstars!

Mastering XPath in Selenium 4 ๐Ÿš€ – Supported Functions & Axes Explained