Question: . When the following is executed, the output is 2, What would the programmed will do the code to get the output as 8?

. When the following is executed, the output is 2, What would 

. When the following is executed, the output is 2, What would the programmed will do the code to get the output as 8? (Hint: Please do not change the values) public class AnswerTest { public static void main(String[] args) { int i 42 + 45 - 48 - 5; int 5+ 5 - 8 + 2; int ansi % j; System.out.printf("%d", ans); } [02 Marks]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To get the output as 8 we need to modify the calculation for the variable i so that it r... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!