Computer Science, asked by riteshverma0901, 1 day ago

if ( a > b)
System.out.println(a+b);
System.out.println (a*b);
when a = 5 and b = 7


a. 12,35
b. 35
c. 35, 12​

Answers

Answered by anindyaadhikari13
5

Output:

  • The output for the program is 35.

Explanation:

In the co‎de given, there are two variables – a and b.

→ a = 5

→ b = 7

Now, let us check whether the condition given is true or false.

a > b

= 5 > 7

= false as 5 is less than 7.

So, the statement inside the if block i.e., System.out.println(a+b); will not be executed.

Now, in the next line, we have the following co‎de:

System.out.println(a * b);

This line will be executed as it is not inside the if block.

So, the output will be:

= 5 * 7

= 35

★ Option (b) is the right answer.

Answered by ItzDαrkHσrsє
2

Here we have been given two variables or no.s i.e they are,

\longrightarrow a = 5

\longrightarrow b = 7

Now let's as per the given two conditions. Moving on to the first condition,

1) System.out.printIn(a+b);

Let's assume,

\longrightarrow \sf{a > b} \\  \\ \longrightarrow \sf{5 > 7}

\therefore Thus, the condition for System.out.printIn(a+b); is not possible.

2) System.out.printIn(a*b);

Placing values of a & b we get,

\longrightarrow \sf{a \times b} \:   \\  \\ \longrightarrow \sf{5 \times 7} \\  \\ \longrightarrow \sf{35}

\therefore Thus, the answer for System.out.printIn(a*b); would be 35.

  • Correct answer for the given question is (B) 35.

Similar questions