Write a Java-program to print logical operators program using &&, || ,!
Program
public class Main
{
public static void main(String args[])
{
int x=10,y=20,z=30
boolean p;
p=x>y && x>z;
System.out.println("p value is: "+(p));
}
}
Output:
p value is: false
Using CommandLine Arguments
public class Main
{
public static void main(String args[])
{
int x,y,z;
boolean p;
x=Integer.parseInt(args[0]);
y=Integer.parseInt(args[1]);
z=Integer.parseInt(args[2]);
p=x>y && x>z;
System.out.println("p value is: "+(p));
}
}
Output:
p value is: false
Using Scanner Class
import java.util.*;
public class Main
{
public static void main(String args[])
{
int x,y,z;
boolean p;
Scanner s=new Scanner(System.in);
System.out.println("Enter x,y,z values");
x=s.nextInt();
y=s.nextInt();
z=s.nextInt();
p=x>y && x>z;
System.out.println("p value is: "+(p));
}
}
Output:
Enter x,y values
10
20
30
p value is: false
More Questions
14 . Write a Java-program to print logical operators program using &&, || ,!
15 . Write a Java-program to print bitwise AND operation
16 . Write a Java-program to print bitwise OR operation
17 . Write a Java-program to print bitwise CAP operation
18 . Write a Java-program to print bitwise NEGATION operation
19 . Write a Java-program to print bitwise LEFT SHIFT operation
20 . Write a Java-program to print bitwise RIGHT SHIFT operation
21 . Write a Java-program to print odd or even number using ternary operator
22 . Write a Java-program to print max number using ternary operator
23 . Write a Java-program to print MAX Number Amoung 3 Numbers
24 . Write a Java-program to print ODD or Even Number using if else condition