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
a
andb
.Calculate the reminder when dividing an integer
dividend
by 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
num1
andnum2
.Determine whether an integer
number
is even or odd.Calculate the area of a rectangle with length
length
and widthwidth
.Determine if an integer
year
is a leap year.Calculate the hypotenuse of a right triangle given the lengths of its two legs
a
andb
.Determine if a given character
ch
is an uppercase letter.Convert temperature from Celsius to Fahrenheit using the formula
F = (C × 9/5) + 32
.Determine if an integer
num
is 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
x
is greater than 10 and less than 20.Calculate the volume of a cylinder given its radius
r
and 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
num
is divisible by both 2 and 3.Calculate the total cost of purchasing
quantity
items atprice
each, 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
num
is a perfect square.Write an expression to find the maximum of two numbers
a
andb
.Determine if a given character
ch
is a vowel.Calculate the factorial of a non-negative integer
n
.Determine if a given year
year
is a leap year.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?