Page 37 - CTS - CSA TP - Volume 2
P. 37
COMPUTER SOFTWARE APPLICATION - CITS
Output:
TASK 10: Java OR Operator Example: Logical || and Bitwise |
public class OperatorExample10{
public static void main(String args[]){
int a=10;
int b=5;
int c=20;
System.out.println(a>b||a<c);//true || true = true
System.out.println(a>b|a<c);//true | true = true
//|| vs |
System.out.println(a>b||a++<c);//true || true = true
System.out.println(a);//10 because second condition is not checked
System.out.println(a>b|a++<c);//true | true = true
System.out.println(a);//11 because second condition is checked
}}
Output:
TASK 11: Java Ternary Operator Example
public class OperatorExample11{
public static void main(String args[]){
int a=2;
int b=5;
int min=(a<b)?a:b;
System.out.println(min);
}}
22
CITS : IT & ITES - Computer Software Application - Exercise 82