Consider the following conditional code, which returns a Boolean values

if ((x > 25) && (y >100))

   return 'false';

else if((x ≤ 25) && (y ≤ 100))

   return 'true';

else if((x > 25) && (y ≤ 100))

      return 'false';

else

   return 'true';

Simplify it by filling in the following blank with a single Boolean expression without changing the behaviour of the conditional code.

if (__________)

    return 'true';

else

    return 'false'; 

This question was previously asked in
UGC NET Computer Science (Paper 2) 11 March 2023 Official Paper
View all UGC NET Papers >
  1. x > 25
  2. x ≤ 25
  3. y >100 
  4. y ≤ 100

Answer (Detailed Solution Below)

Option 2 : x ≤ 25
Free
UGC NET Paper 1: Held on 21st August 2024 Shift 1
10.9 K Users
50 Questions 100 Marks 60 Mins

Detailed Solution

Download Solution PDF

The correct answer is x ≤ 25

EXPLANATION:Here the code:

    if ((x ≤ 25) || (y > 100))
       return 'true';
    else
       return 'false';

This code aims to achieve the same result as the above code provided. Let's analyze the conditions:

  • (x ≤ 25): This condition is true when x is less than or equal to 25.
  • (y > 100): This condition is true when y is greater than 100.
  • The || (logical OR) operator is used between these conditions. In the simplified code:
  • If either (x ≤ 25) is true or (y > 100) is true (or both), the entire expression evaluates to true.
  • If neither condition is true, the entire expression evaluates to false.

So, the code essentially says: Return 'true' if either x is less than or equal to 25 or y is greater than 100. Return 'false' otherwise.

Latest UGC NET Updates

Last updated on Jun 12, 2025

-> The UGC NET June 2025 exam will be conducted from 25th to 29th June 2025.

-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.

-> The exam is conducted bi-annually - in June and December cycles.

-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions. 

-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.

Get Free Access Now
Hot Links: teen patti gold real cash teen patti wink teen patti real cash apk teen patti sequence