Operators and Expressions

Let's test your knowledge on operators and expressions in Java with the following problem statements:

  1. Write an expression to add two integers a and b.

  2. Calculate the reminder when dividing an integer dividend by another integer divisor.

  3. Evaluate the expression 5 * (10 + 3).

  4. Find the result of the expression (8 - 3) * 2 / 5.

  5. Determine the value of the expression 10 % 3.

  6. Calculate the average of two numbers num1 and num2.

  7. Determine whether an integer number is even or odd.

  8. Calculate the area of a rectangle with length length and width width.

  9. Determine if an integer year is a leap year.

  10. Calculate the hypotenuse of a right triangle given the lengths of its two legs a and b.

  11. Determine if a given character ch is an uppercase letter.

  12. Convert temperature from Celsius to Fahrenheit using the formula F = (C × 9/5) + 32.

  13. Determine if an integer num is a multiple of 5.

  14. Calculate the perimeter of a square with side length side.

  15. Determine the result of the expression (10 > 5) && (8 < 3).

  16. Determine the result of the expression (true || false) && (true && false).

  17. Evaluate the expression (4 * 3) == (6 * 2).

  18. Determine the result of the expression !(5 >= 10).

  19. Calculate the square of a number x.

  20. Determine the result of the expression (7 != 5) || (3 <= 3).

  21. Write an expression to calculate the area of a circle with radius r.

  22. Calculate the value of the expression (5 + 3) * 2.

  23. Determine the result of the expression (10 - 4) / 2.

  24. Evaluate the expression 2 * (3 + 4) - 5.

  25. Write an expression to convert temperature from Celsius to Fahrenheit using the formula F = (C × 9/5) + 32.

  26. Calculate the average of three numbers num1, num2, and num3.

  27. Determine if a given number x is greater than 10 and less than 20.

  28. Calculate the volume of a cylinder given its radius r and height h.

  29. Determine the result of the expression 5 * 3 - 2 / 4.

  30. Write an expression to calculate the square root of a number x.

  31. Determine if a given number num is divisible by both 2 and 3.

  32. Calculate the total cost of purchasing quantity items at price each, including a sales tax of 8%.

  33. Determine the result of the expression (4 + 5) == (7 - 2).

  34. Calculate the distance between two points (x1, y1) and (x2, y2) using the distance formula.

  35. Determine if a given number num is a perfect square.

  36. Write an expression to find the maximum of two numbers a and b.

  37. Determine if a given character ch is a vowel.

  38. Calculate the factorial of a non-negative integer n.

  39. Determine if a given year year is a leap year.

  40. Write an expression to check if a given number num is positive, negative, or zero.

These problems cover various types of operators and expressions in Java, including arithmetic, relational, logical, and conditional expressions.

Last updated

Was this helpful?