150k views
5 votes
What is the output of the following code snippet? final int COST = 583; int digit = COST % 10; if (digit != 500) { System.out.println("500"); } else { System.out.println("Not 500"); } There is no output due to compilation errors. 500 Not 500 500 Not 500

User Agillgilla
by
5.4k points

1 Answer

4 votes

Answer:

500

Step-by-step explanation:

  • COST = 583

583 % 10 = 3

  • digit = 3

if (digit != 500) then print "500"

3 != 500 ---> System.out.println("500");

User Geomagas
by
5.7k points