Computer Applications

if (a>b&&b>c) then largest number is:

  1. b
  2. c
  3. a
  4. wrong expression

Java Operators

ICSE 2024

5 Likes

Answer

a

Reason — The && (Logical AND) operator in Java is used to combine two boolean expressions. It returns true only if both expressions are true. If either of the expressions is false, the entire condition becomes false.

The condition if (a > b && b > c) checks two expressions:

  1. a > b – Checks if a is greater than b.
  2. b > c – Checks if b is greater than c.

Since both conditions must be true (due to the && operator), the logical sequence becomes:
a > b > c

In this sequence:
a is the largest number because it is greater than both b and c.

Answered By

3 Likes


Related Questions