Operators and Expressions
Let's test your knowledge on operators and expressions in Java with the following problem statements:
Write an expression to add two integers
aandb.Calculate the reminder when dividing an integer
dividendby another integerdivisor.Evaluate the expression
5 * (10 + 3).Find the result of the expression
(8 - 3) * 2 / 5.Determine the value of the expression
10 % 3.Calculate the average of two numbers
num1andnum2.Determine whether an integer
numberis even or odd.Calculate the area of a rectangle with length
lengthand widthwidth.Determine if an integer
yearis a leap year.Calculate the hypotenuse of a right triangle given the lengths of its two legs
aandb.Determine if a given character
chis an uppercase letter.Convert temperature from Celsius to Fahrenheit using the formula
F = (C × 9/5) + 32.Determine if an integer
numis a multiple of 5.Calculate the perimeter of a square with side length
side.Determine the result of the expression
(10 > 5) && (8 < 3).Determine the result of the expression
(true || false) && (true && false).Evaluate the expression
(4 * 3) == (6 * 2).Determine the result of the expression
!(5 >= 10).Calculate the square of a number
x.Determine the result of the expression
(7 != 5) || (3 <= 3).Write an expression to calculate the area of a circle with radius
r.Calculate the value of the expression
(5 + 3) * 2.Determine the result of the expression
(10 - 4) / 2.Evaluate the expression
2 * (3 + 4) - 5.Write an expression to convert temperature from Celsius to Fahrenheit using the formula
F = (C × 9/5) + 32.Calculate the average of three numbers
num1,num2, andnum3.Determine if a given number
xis greater than 10 and less than 20.Calculate the volume of a cylinder given its radius
rand heighth.Determine the result of the expression
5 * 3 - 2 / 4.Write an expression to calculate the square root of a number
x.Determine if a given number
numis divisible by both 2 and 3.Calculate the total cost of purchasing
quantityitems atpriceeach, including a sales tax of 8%.Determine the result of the expression
(4 + 5) == (7 - 2).Calculate the distance between two points
(x1, y1)and(x2, y2)using the distance formula.Determine if a given number
numis a perfect square.Write an expression to find the maximum of two numbers
aandb.Determine if a given character
chis a vowel.Calculate the factorial of a non-negative integer
n.Determine if a given year
yearis a leap year.Write an expression to check if a given number
numis 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?