-
Add 10 to the numberOfItems variable.
class Main { public static void main(String[] args) { int numberOfItems = 30; numberOfItems = "" } }
-
Subtract 5 from the speed variable.
class Main { public static void main(String[] args) { int speed = 120; speed = speed "" 10; } }
-
Add 2000 to the marketingBudget variable.
class Main { public static void main(String[] args) { int marketingBudget = 10000; marketingBudget "" 2000; } }
-
Subtract 1.75 from the marketShare variable.
class Main { public static void main(String[] args) { double marketShare = 20.0; marketShare "" 1.75; } }
-
What is the output of this code?
class Main { public static void main(String[] args) { double wallet = 500.0; double maintenance = 300.0; double remainedMoney = wallet - maintenance; System.out.println(remainedMoney); } }
-
Imagine a customer has accumulated 500 reward points, and they earn an additional 25 points on their recent purchase. What will be the value of the total_points variable?
class Main { public static void main(String[] args) { int totalCost = 50000; byte numberOfDepartments = 5; double costPerDepartment = totalCost / numberOfDepartments; System.out.println(costPerDepartment); } }
Java Exercises for Operators
If you’ve faced difficulties with these exercises, take a look at Operators Module on my Java course.
You can also share ‘Java Operators’ Exercises on your:
X (Twitter) – Telegram – Linkedin – Facebook – or on your favorite platform…