52.4k views
2 votes
Consider the following code segment, which uses the int value a. if ((a > 12) || (a < 4)) System.out.println("New value: " + a/3); else System.out.println("New value: " + 2*a); For which, if any, of the following initial values of a will the statement "New value: 4" be printed when the code is executed?

User Bretsko
by
7.9k points

1 Answer

7 votes

Answer:

a = 13 and 14

Explanation:

The "/" does ordinary division when applied. So when a = 13 and a = 14, both greater than 12, it found the values 4,33 and 4,66, respectively, and java itself round it to 4.

User Chlebta
by
8.8k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories