✅ 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)

Selenium WebDriver commands grouped by Browser Commands, WebElement Commands, and Navigation Commands.

🧭 Complete Guide to Selenium Locators & Element Finding Strategies