The correct if statement for the following ternary operation statement is:

System.out.println(n%2 == 0? “true”:” false”);
  1. if(n%2==0)
    return true;
    else return false;
  2. if(n%2==0)
    return “true”;
    else
    return “false”;
  3. if(n%2==0)
    System.out.printIn(“true”);
    else
    System.out.println(“false”);
  4. if(n%2==0)
    return false;
    else
    return false;


Solution



(c)
if(n%2==0)
System.out.printIn(“true”);
else
System.out.println(“false”);

Explanation:

Here,we have to print true or false,rather than returning any boolean value so,answer for this is c option


Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com